grab 0.0.0.6 → 0.0.0.7
raw patch · 2 files changed
+52/−57 lines, 2 filesdep ~basedep ~criteriondep ~hedgehogPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, criterion, hedgehog
API changes (from Hackage documentation)
Files
- changelog.md +5/−0
- grab.cabal +47/−57
+ changelog.md view
@@ -0,0 +1,5 @@+# Changelog++## 0.0.0.7 - 2022 March 14++Support base-4.16, hedgehog-1.1
grab.cabal view
@@ -1,57 +1,57 @@-cabal-version: 2.4+cabal-version: 3.0 name: grab-version: 0.0.0.6+version: 0.0.0.7 synopsis: Applicative non-linear consumption category: Control description: == The Grab type- .+ A grab consumes some portion (none, part, or all) of its input @bag@, and returns a @residue@ consisting of the unconsumed input, some monoidal @log@ (e.g. a list of error messages), and some @desideratum@ (the object of desire) produced from the consumed input, or @Nothing@ if the grab failed.- .+ > newtype Grab bag residue log desideratum = > Grab ( > bag -> (residue, log, Maybe desideratum) > )- .+ Grabs are useful as parsers for inputs such as JSON objects or lists of form parameters, where the input data is not necessarily given linearly in the same order in which we want to consume it.- .+ == Applicative composition- .+ A @Simple@ grab (where the @bag@ and @residue@ are the same type) has an @Applicative@ instance.- .+ > instance (bag ~ residue, Monoid log) => > Applicative (Grab bag residue log)- .+ For example, we can create two simple list grabs, one that grabs multiples of two, and the other that grabs multiples of three:- .+ > twos, threes :: Monoid log => > Control.Grab.Simple [Integer] log [Integer] > twos = partition (Data.List.partition (\x -> mod x 2 == 0)) > threes = partition (Data.List.partition (\x -> mod x 3 == 0))- .+ > λ> runGrabMaybe ((,) <$> twos @() <*> threes @()) [1..10] > Just ([2,4,6,8,10],[3,9])- .+ Notice that the second part of the resulting tuple contains only the /odd/ multiples of three. Because @twos@ runs first, it consumes @6@ before the @threes@ can get it.- .+ == Pipeline composition- .+ @a / b@ is a pipeline of two grabs, where the desideratum from @a@ is the @bag@ for @b@. .@@ -59,10 +59,10 @@ > => Grab bag residue log x > -> Grab x _residue log desideratum > -> Grab bag residue log desideratum- .+ > λ> runGrabMaybe (twos @() / threes @()) [1..10] > Just [6]- .+ > λ> runGrabMaybe ((,) <$> (twos @() / threes @()) <*> threes @()) [1..10] > Just ([6],[3,9]) @@ -76,31 +76,29 @@ license: MIT license-file: license.txt -tested-with: GHC==8.6.5, GHC==8.8.1, GHC==8.10.4, GHC==9.0.1+extra-source-files:+ changelog.md -library- hs-source-dirs: src- default-language: Haskell2010- ghc-options: -fdefer-typed-holes- exposed-modules: Control.Grab+common base+ default-language: Haskell2010+ build-depends:+ base ^>= 4.12 || ^>= 4.13 || ^>= 4.14 || ^>= 4.15 || ^>= 4.16 - build-depends: base- build-depends: base >= 4.12- build-depends: base < 4.16+library+ import: base+ hs-source-dirs: src+ ghc-options: -fdefer-typed-holes+ exposed-modules: Control.Grab test-suite hedgehog- type: exitcode-stdio-1.0- default-language: Haskell2010- hs-source-dirs: test- main-is: hedgehog.hs-- build-depends: base, grab, hedgehog-- build-depends: base >= 4.12- build-depends: hedgehog >= 1.0+ import: base+ type: exitcode-stdio-1.0+ hs-source-dirs: test+ main-is: hedgehog.hs - build-depends: base < 4.16- build-depends: hedgehog < 1.1+ build-depends:+ grab+ , hedgehog ^>= 1.0 || ^>= 1.1 -- This benchmark runs with a tightly limited stack size -- to detect space leaks, as described by:@@ -111,28 +109,20 @@ -- stack bench grab:space --profile --ba "+RTS -xc" -- benchmark space- type: exitcode-stdio-1.0- hs-source-dirs: bench- main-is: space.hs- default-language: Haskell2010- ghc-options: "-with-rtsopts=-K1K"-- build-depends: base, grab-- build-depends: base >= 4.12+ import: base+ type: exitcode-stdio-1.0+ hs-source-dirs: bench+ main-is: space.hs+ ghc-options: "-with-rtsopts=-K1K" - build-depends: base < 4.15+ build-depends: grab benchmark time- type: exitcode-stdio-1.0- hs-source-dirs: bench- main-is: time.hs- default-language: Haskell2010-- build-depends: base, criterion, grab-- build-depends: base >= 4.12- build-depends: criterion >= 1.5+ import: base+ type: exitcode-stdio-1.0+ hs-source-dirs: bench+ main-is: time.hs - build-depends: base < 4.16- build-depends: criterion < 1.6+ build-depends:+ criterion ^>= 1.5+ , grab