packages feed

foldl 1.3.3 → 1.3.4

raw patch · 4 files changed

+31/−2 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Foldl: prefilter :: (a -> Bool) -> Fold a r -> Fold a r
+ Control.Foldl: prefilterM :: (Monad m) => (a -> m Bool) -> FoldM m a r -> FoldM m a r

Files

CHANGELOG.md view
@@ -1,3 +1,7 @@+1.3.4++* Add `prefilter` and `prefilterM`+ 1.3.3  * Add back the old `vector` as `vectorM`
README.md view
@@ -1,4 +1,4 @@-# `foldl` v1.3.3+# `foldl` v1.3.4  Use this `foldl` library when you want to compute multiple folds over a collection in one pass over the data without space leaks.
foldl.cabal view
@@ -1,5 +1,5 @@ Name: foldl-Version: 1.3.3+Version: 1.3.4 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3
src/Control/Foldl.hs view
@@ -119,6 +119,8 @@     , _Fold1     , premap     , premapM+    , prefilter+    , prefilterM     , Handler     , handles     , foldOver@@ -1122,6 +1124,29 @@   where     step' x a = step x (f a) {-# INLINABLE premapM #-}++{-| @(prefilter f folder)@ returns a new 'Fold' where the folder's input is used+  only when the input satisfies a predicate f++  This can also be done with 'handles' (@handles (filtered f)@) but @prefilter@+  does not need you to depend on a lens library.+-}+prefilter :: (a -> Bool) -> Fold a r -> Fold a r+prefilter f (Fold step begin done) = Fold step' begin done+  where+    step' x a = if f a then step x a else x+{-# INLINABLE prefilter #-}++{-| @(prefilterM f folder)@ returns a new 'Fold' where the folder's input is used+  only when the input satisfies a monadic predicate f.+-}+prefilterM :: (Monad m) => (a -> m Bool) -> FoldM m a r -> FoldM m a r+prefilterM f (FoldM step begin done) = FoldM step' begin done+  where+    step' x a = do+      use <- f a+      if use then step x a else return x+{-# INLINABLE prefilterM #-}  {-| A handler for the upstream input of a `Fold`