packages feed

grab 0.0.0.7 → 0.0.0.8

raw patch · 8 files changed

+234/−230 lines, 8 filesdep ~basedep ~hedgehogPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, hedgehog

API changes (from Hackage documentation)

Files

− bench/space.hs
@@ -1,39 +0,0 @@-{-# OPTIONS_GHC -Wall #-}--{-# LANGUAGE ApplicativeDo, BlockArguments #-}--import Prelude hiding ((/))--import qualified Control.Grab as Grab-import Control.Grab ((/))--import qualified Data.List as List-import qualified Data.Foldable as Foldable--import Data.Monoid--main :: IO ()-main =-  do-    let r = Grab.runGrab g [1..30000]-    putStrLn ("desideratum: " ++ show (Grab.desideratum r))-    putStrLn ("log: " ++ show (Grab.log r))--f :: Monoid log => (a -> Bool) -> Grab.Simple [a] log [a]-f p = Grab.partition (List.partition p)--g :: Grab.Simple [Integer] (Sum Integer) (Integer, Integer)-g =-  do-    _ <- Foldable.for_ primes \n ->-           ( f (\x -> mod x n == 0)-           / Grab.dump (\xs -> Grab.warning (Sum $! sum xs))-           )--    evenSum  <- sum <$> f even-    oddSum   <- sum <$> f odd--    pure (evenSum, oddSum)--primes :: [Integer]-primes = [5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79]
+ bench/space/Main.hs view
@@ -0,0 +1,39 @@+{-# OPTIONS_GHC -Wall #-}++{-# LANGUAGE ApplicativeDo, BlockArguments #-}++import Prelude hiding ((/))++import qualified Control.Grab as Grab+import Control.Grab ((/))++import qualified Data.List as List+import qualified Data.Foldable as Foldable++import Data.Monoid++main :: IO ()+main =+  do+    let r = Grab.runGrab g [1..30000]+    putStrLn ("desideratum: " ++ show (Grab.desideratum r))+    putStrLn ("log: " ++ show (Grab.log r))++f :: Monoid log => (a -> Bool) -> Grab.Simple [a] log [a]+f p = Grab.partition (List.partition p)++g :: Grab.Simple [Integer] (Sum Integer) (Integer, Integer)+g =+  do+    _ <- Foldable.for_ primes \n ->+           ( f (\x -> mod x n == 0)+           / Grab.dump (\xs -> Grab.warning (Sum $! sum xs))+           )++    evenSum  <- sum <$> f even+    oddSum   <- sum <$> f odd++    pure (evenSum, oddSum)++primes :: [Integer]+primes = [5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79]
− bench/time.hs
@@ -1,27 +0,0 @@-{-# OPTIONS_GHC -Wall #-}--import qualified Control.Grab as Grab--import Criterion.Main--import qualified Data.List as List-import Prelude hiding (filter)--parity :: Integer -> Maybe (Integer, Integer)-parity n = Grab.desideratum (Grab.runGrab g [1..n])-  where-    g = (,) <$> (sum <$> filter even) <*> (sum <$> filter odd)--filter :: (a -> Bool) -> Grab.Simple [a] () [a]-filter p = Grab.partition (List.partition p)--main :: IO ()-main = defaultMain [-  bgroup "parity"-    (-      (\i -> let n = i * 10000 in-        bench (show i) (nf parity n)-      )-      <$> [1..4]-    )-  ]
+ bench/time/Main.hs view
@@ -0,0 +1,27 @@+{-# OPTIONS_GHC -Wall #-}++import qualified Control.Grab as Grab++import Criterion.Main++import qualified Data.List as List+import Prelude hiding (filter)++parity :: Integer -> Maybe (Integer, Integer)+parity n = Grab.desideratum (Grab.runGrab g [1..n])+  where+    g = (,) <$> (sum <$> filter even) <*> (sum <$> filter odd)++filter :: (a -> Bool) -> Grab.Simple [a] () [a]+filter p = Grab.partition (List.partition p)++main :: IO ()+main = defaultMain [+  bgroup "parity"+    (+      (\i -> let n = i * 10000 in+        bench (show i) (nf parity n)+      )+      <$> [1..4]+    )+  ]
changelog.md view
@@ -3,3 +3,7 @@ ## 0.0.0.7 - 2022 March 14  Support base-4.16, hedgehog-1.1++## 0.0.0.8 - 2022 Jun 20++Fix build for case-insensitive file systems
grab.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: grab-version: 0.0.0.7+version: 0.0.0.8  synopsis: Applicative non-linear consumption category: Control@@ -90,11 +90,11 @@     ghc-options: -fdefer-typed-holes     exposed-modules: Control.Grab -test-suite hedgehog+test-suite grab-test     import: base     type: exitcode-stdio-1.0     hs-source-dirs: test-    main-is: hedgehog.hs+    main-is: Main.hs      build-depends:         grab@@ -108,20 +108,20 @@ -- --     stack bench grab:space --profile --ba "+RTS -xc" ---benchmark space+benchmark grab-space-bench     import: base     type: exitcode-stdio-1.0-    hs-source-dirs: bench-    main-is: space.hs+    hs-source-dirs: bench/space+    main-is: Main.hs     ghc-options: "-with-rtsopts=-K1K"      build-depends: grab -benchmark time+benchmark grab-time-bench     import: base     type: exitcode-stdio-1.0-    hs-source-dirs: bench-    main-is: time.hs+    hs-source-dirs: bench/time+    main-is: Main.hs      build-depends:         criterion ^>= 1.5
+ test/Main.hs view
@@ -0,0 +1,155 @@+{-# OPTIONS_GHC++    -Wall+    -fno-warn-unused-imports+    -fno-warn-missing-signatures++#-}++{-# LANGUAGE++    BlockArguments, LambdaCase, OverloadedStrings,+    ScopedTypeVariables, TemplateHaskell, ViewPatterns++#-}++import qualified Control.Grab as Grab+import Control.Grab ((/))++import Prelude hiding ((/))++import           Hedgehog+import qualified Hedgehog.Gen as Gen+import qualified Hedgehog.Range as Range++import Control.Monad (when)+import qualified Data.List as List++import System.IO (hSetEncoding, stdout, stderr, utf8)+import System.Exit (exitFailure)++tests :: IO Bool+tests =+  checkParallel $$(discover)++example =+    withTests 1 . property++x ~> y =+    example (x === y)++main :: IO ()+main =+  do+    hSetEncoding stdout utf8+    hSetEncoding stderr utf8+    ok <- tests+    when (not ok) exitFailure++prop_1 =+    let+        r = Grab.failure "a" *>+            Grab.failure "b" *>+            Grab.failure "c"+            :: Grab.Extract String Integer+    in+        (Grab.log r, Grab.desideratum r)+        ~>+        ("abc", Nothing)++prop_2 =+    let+        r = Grab.failure "a" *>+            Grab.failure "b" *>+            Grab.success (4 :: Integer)+    in+        (Grab.log r, Grab.desideratum r )+        ~>+        ("ab" :: String, Nothing)++prop_3 =+    let+        r = Grab.success 4 :: Grab.Extract String Integer+    in+        Grab.desideratum r ~> Just 4++prop_4 =+    let+        g :: Grab.Simple [Integer] () (Integer, Integer)+        g =+            (,)+                <$> ( Grab.partition (List.partition even)+                    / Grab.dump (\_ -> Grab.failure ())+                    )+                <*> ( Grab.partition (List.partition odd)+                    / Grab.dump (\xs -> Grab.success (sum xs))+                    )++        r = Grab.runGrab g undefined++    in+        Grab.desideratum r ~> Nothing++prop_5 =+    let+        g :: Grab.Simple [Integer] () (Integer, Integer)+        g =+            (,)+                <$> ( Grab.partition (List.partition even)+                    / Grab.dump (\xs -> Grab.success (sum xs))+                    )+                <*> ( Grab.partition (List.partition odd)+                    / Grab.dump (\_ -> Grab.failure ())+                    )++        r = Grab.runGrab g undefined++    in+        Grab.desideratum r ~> Nothing++prop_6 =+    let+        g :: Grab.Simple [Integer] () Integer+        g =+            ( Grab.partition (List.partition even)+            / Grab.dump (\xs -> Grab.success (sum xs))+            )++        r = Grab.runGrab g [1,2,3,4]++    in+        Grab.desideratum r ~> Just 6++prop_7 =+    let+        g :: Grab.Simple [Integer] () (Integer, Integer)+        g =+            (,)+                <$> ( Grab.partition (List.partition even)+                    / Grab.dump (\xs -> Grab.success (sum xs))+                    )+                <*> ( Grab.partition (List.partition odd)+                    / Grab.dump (\xs -> Grab.success (sum xs))+                    )++        r = Grab.runGrab g [1,2,3,4]++    in+        Grab.desideratum r ~> Just (6, 4)++prop_8 =+    let+        g :: Grab.Simple [Integer] () (Integer, Integer)+        g =+            (,)+                <$> ( Grab.partition (List.partition even)+                    / Grab.dump (\xs -> Grab.success (sum xs))+                    )+                <*> ( Grab.partition (List.partition odd)+                    / Grab.dump (\xs -> if elem 3 xs then Grab.failure () else Grab.success (sum xs))+                    )++        r = Grab.runGrab g (1:2:3:undefined)++    in+        Grab.desideratum r ~> Nothing
− test/hedgehog.hs
@@ -1,155 +0,0 @@-{-# OPTIONS_GHC--    -Wall-    -fno-warn-unused-imports-    -fno-warn-missing-signatures--#-}--{-# LANGUAGE--    BlockArguments, LambdaCase, OverloadedStrings,-    ScopedTypeVariables, TemplateHaskell, ViewPatterns--#-}--import qualified Control.Grab as Grab-import Control.Grab ((/))--import Prelude hiding ((/))--import           Hedgehog-import qualified Hedgehog.Gen as Gen-import qualified Hedgehog.Range as Range--import Control.Monad (when)-import qualified Data.List as List--import System.IO (hSetEncoding, stdout, stderr, utf8)-import System.Exit (exitFailure)--tests :: IO Bool-tests =-  checkParallel $$(discover)--example =-    withTests 1 . property--x ~> y =-    example (x === y)--main :: IO ()-main =-  do-    hSetEncoding stdout utf8-    hSetEncoding stderr utf8-    ok <- tests-    when (not ok) exitFailure--prop_1 =-    let-        r = Grab.failure "a" *>-            Grab.failure "b" *>-            Grab.failure "c"-            :: Grab.Extract String Integer-    in-        (Grab.log r, Grab.desideratum r)-        ~>-        ("abc", Nothing)--prop_2 =-    let-        r = Grab.failure "a" *>-            Grab.failure "b" *>-            Grab.success (4 :: Integer)-    in-        (Grab.log r, Grab.desideratum r )-        ~>-        ("ab" :: String, Nothing)--prop_3 =-    let-        r = Grab.success 4 :: Grab.Extract String Integer-    in-        Grab.desideratum r ~> Just 4--prop_4 =-    let-        g :: Grab.Simple [Integer] () (Integer, Integer)-        g =-            (,)-                <$> ( Grab.partition (List.partition even)-                    / Grab.dump (\_ -> Grab.failure ())-                    )-                <*> ( Grab.partition (List.partition odd)-                    / Grab.dump (\xs -> Grab.success (sum xs))-                    )--        r = Grab.runGrab g undefined--    in-        Grab.desideratum r ~> Nothing--prop_5 =-    let-        g :: Grab.Simple [Integer] () (Integer, Integer)-        g =-            (,)-                <$> ( Grab.partition (List.partition even)-                    / Grab.dump (\xs -> Grab.success (sum xs))-                    )-                <*> ( Grab.partition (List.partition odd)-                    / Grab.dump (\_ -> Grab.failure ())-                    )--        r = Grab.runGrab g undefined--    in-        Grab.desideratum r ~> Nothing--prop_6 =-    let-        g :: Grab.Simple [Integer] () Integer-        g =-            ( Grab.partition (List.partition even)-            / Grab.dump (\xs -> Grab.success (sum xs))-            )--        r = Grab.runGrab g [1,2,3,4]--    in-        Grab.desideratum r ~> Just 6--prop_7 =-    let-        g :: Grab.Simple [Integer] () (Integer, Integer)-        g =-            (,)-                <$> ( Grab.partition (List.partition even)-                    / Grab.dump (\xs -> Grab.success (sum xs))-                    )-                <*> ( Grab.partition (List.partition odd)-                    / Grab.dump (\xs -> Grab.success (sum xs))-                    )--        r = Grab.runGrab g [1,2,3,4]--    in-        Grab.desideratum r ~> Just (6, 4)--prop_8 =-    let-        g :: Grab.Simple [Integer] () (Integer, Integer)-        g =-            (,)-                <$> ( Grab.partition (List.partition even)-                    / Grab.dump (\xs -> Grab.success (sum xs))-                    )-                <*> ( Grab.partition (List.partition odd)-                    / Grab.dump (\xs -> if elem 3 xs then Grab.failure () else Grab.success (sum xs))-                    )--        r = Grab.runGrab g (1:2:3:undefined)--    in-        Grab.desideratum r ~> Nothing