packages feed

foldl 1.2.0 → 1.2.1

raw patch · 2 files changed

+31/−11 lines, 2 filesdep ~transformersPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: transformers

API changes (from Hackage documentation)

+ Control.Foldl: filtered :: Monoid m => (a -> Bool) -> (a -> m) -> a -> m

Files

foldl.cabal view
@@ -1,5 +1,5 @@ Name: foldl-Version: 1.2.0+Version: 1.2.1 Cabal-Version: >=1.8.0.2 Build-Type: Simple License: BSD3@@ -7,6 +7,7 @@ Copyright: 2013 Gabriel Gonzalez Author: Gabriel Gonzalez Maintainer: Gabriel439@gmail.com+Tested-With: GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2, GHC == 8.0.1 Bug-Reports: https://github.com/Gabriel439/Haskell-Foldl-Library/issues Synopsis: Composable, streaming, and efficient left folds Description: This library provides strict left folds that stream in constant@@ -26,7 +27,7 @@         mwc-random   >= 0.13.1.0 && < 0.14,         primitive                   < 0.7 ,         text         >= 0.11.2.0 && < 1.3 ,-        transformers >= 0.2.0.0  && < 0.5 ,+        transformers >= 0.2.0.0  && < 0.6 ,         vector       >= 0.7      && < 0.12,         containers                  < 0.6 ,         contravariant               < 1.5 ,
src/Control/Foldl.hs view
@@ -19,7 +19,7 @@     Taking the sum, the sum of squares, ..., upto the sum of x^5  >>> import Data.Traversable->>> let powerSums = sequenceA [premap (^n) L.sum | n <- [1..5]]+>>> let powerSums = sequenceA [L.premap (^n) L.sum | n <- [1..5]] >>> L.fold powerSums [1..10] [55,385,3025,25333,220825] @@ -109,6 +109,7 @@     , HandlerM     , handlesM     , folded+    , filtered      -- * Re-exports     -- $reexports@@ -172,7 +173,7 @@  instance Functor (Fold a) where     fmap f (Fold step begin done) = Fold step begin (f . done)-    {-# INLINABLE fmap #-}+    {-# INLINE fmap #-}  instance Profunctor Fold where     lmap = premap@@ -187,14 +188,14 @@  instance Applicative (Fold a) where     pure b    = Fold (\() _ -> ()) () (\() -> b)-    {-# INLINABLE pure #-}+    {-# INLINE pure #-}      (Fold stepL beginL doneL) <*> (Fold stepR beginR doneR) =         let step (Pair xL xR) a = Pair (stepL xL a) (stepR xR a)             begin = Pair beginL beginR             done (Pair xL xR) = doneL xL (doneR xR)         in  Fold step begin done-    {-# INLINABLE (<*>) #-}+    {-# INLINE (<*>) #-}  instance Monoid b => Monoid (Fold a b) where     mempty = pure mempty@@ -557,7 +558,7 @@ -} maximumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) maximumBy cmp = _Fold1 max'-  where +  where     max' x y = case cmp x y of         GT -> x         _  -> y@@ -573,7 +574,7 @@ -} minimumBy :: (a -> a -> Ordering) -> Fold a (Maybe a) minimumBy cmp = _Fold1 min'-  where +  where     min' x y = case cmp x y of         GT -> y         _  -> x@@ -823,11 +824,11 @@  > ofoldlUnwrap >     :: MonoFoldable mono->     => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b +>     => (x -> Element mono -> x) -> x -> (x -> b) -> mono -> b > > ofoldMUnwrap >     :: (Monad m, MonoFoldable mono)->     => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b +>     => (x -> Element mono -> m x) -> m x -> (x -> m b) -> mono -> m b      You can wrap these to accept 'Fold' or 'FoldM', too: @@ -990,7 +991,7 @@ 42  >>> fold (handles (filtered even) sum) [1..10]-42+30  >>> fold (handles _2 mconcat) [(1,"Hello "),(2,"World"),(3,"!")] "Hello World!"@@ -1060,6 +1061,24 @@     :: (Contravariant f, Applicative f, Foldable t)     => (a -> f a) -> (t a -> f (t a)) folded k ts = contramap (\_ -> ()) (F.traverse_ k ts)++{-|+>>> fold (handles (filtered even) sum) [1..10]+30++>>> foldM (handlesM (filtered even) (mapM_ print)) [1..10]+2+4+6+8+10++-}+filtered :: Monoid m => (a -> Bool) -> (a -> m) -> a -> m+filtered p k x+    | p x = k x+    | otherwise = mempty+{-# INLINABLE filtered #-}  {- $reexports     @Control.Monad.Primitive@ re-exports the 'PrimMonad' type class