number-wall 0.1.0.2 → 0.1.0.3
raw patch · 4 files changed
+47/−5 lines, 4 filesdep +chimeradep +tasty-benchdep −memoizedep ~basePVP ok
version bump matches the API change (PVP)
Dependencies added: chimera, tasty-bench
Dependencies removed: memoize
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- CHANGELOG.md +5/−0
- bench/Main.hs +13/−0
- number-wall.cabal +15/−3
- src/NumberWall.hs +14/−2
CHANGELOG.md view
@@ -14,3 +14,8 @@ * Removed formal definition. * Added section headings in documentation. * Removed unnecessary `Show` constraint.++## 0.1.0.3 -- 2022-9-3++* Improved performance (thanks to Bodigrim).+* Fixed source repository name.
+ bench/Main.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE DataKinds #-}++module Main where++import NumberWall+import Test.Tasty.Bench++showPagoda n =+ showSection show (0, n * 2) (0, n) $ numberWall ((pagoda :: Int -> Mod 2) . (+ n))++main = defaultMain+ [ bench "showPagoda" $ nf showPagoda 256+ ]
number-wall.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: number-wall-version: 0.1.0.2+version: 0.1.0.3 author: Owen Bechtel maintainer: ombspring@gmail.com @@ -28,7 +28,7 @@ source-repository head type: git- location: https://github.com/UnaryPlus/lambda.git+ location: https://github.com/UnaryPlus/number-wall.git library hs-source-dirs: src@@ -38,7 +38,7 @@ build-depends: base >= 4.14.1.0 && < 5,- memoize >= 0.2.0 && < 1.2,+ chimera >= 0.3.2.0 && < 0.4, mod >= 0.1.1.0 && < 0.2, semirings >= 0.5.2 && < 0.8, JuicyPixels >= 3.3 && < 3.4@@ -53,3 +53,15 @@ build-depends: base, number-wall++benchmark bench+ type: exitcode-stdio-1.0+ hs-source-dirs: bench+ default-language: Haskell2010+ ghc-options: -W+ main-is: Main.hs++ build-depends:+ base,+ number-wall,+ tasty-bench
src/NumberWall.hs view
@@ -16,6 +16,7 @@ {-# LANGUAGE BlockArguments #-} {-# LANGUAGE ConstraintKinds #-}+{-# LANGUAGE ScopedTypeVariables #-} module NumberWall ( -- * Creating number walls Col, Row, numberWall, NumberWall@@ -29,12 +30,13 @@ import Prelude hiding (negate, (*), (+), (-), (^), quot) -import Data.Function.Memoize (memoFix2)+import Data.Chimera (VChimera, index, tabulateFix')+import Data.Chimera.ContinuousMapping (fromZCurve, toZCurve, wordToInt, intToWord) import Data.Semiring (Semiring, Ring, zero, one, negate, (*), (+), (-), (^)) import Data.Euclidean (Euclidean, quot) -import Data.Mod.Word import Codec.Picture (PixelRGB8(..), generateImage, writePng)+import Data.Mod.Word import Data.Word (Word8) {-|@@ -52,6 +54,16 @@ sign :: Ring a => Int -> a sign x = if even x then one else negate one++memoFix2 :: forall a. ((Int -> Int -> a) -> (Int -> Int -> a)) -> (Int -> Int -> a)+memoFix2 f = uncast $ index (tabulateFix' (cast . f . uncast) :: VChimera a)+ where+ cast :: (Int -> Int -> a) -> (Word -> a)+ cast f = \n -> let (x, y) = fromZCurve n in+ f (wordToInt x) (wordToInt y)++ uncast :: (Word -> a) -> (Int -> Int -> a)+ uncast g = \x y -> g (toZCurve (intToWord x) (intToWord y)) {-| Generate the number wall for a sequence.