deferred-folds 0.4.1 → 0.5
raw patch · 3 files changed
+20/−13 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- DeferredFolds.Unfold: foldl' :: (output -> input -> output) -> output -> Unfold input -> output
- DeferredFolds.Unfold: instance Data.Semigroup.Semigroup (DeferredFolds.Unfold.Unfold a)
- DeferredFolds.UnfoldM: foldl' :: (output -> input -> output) -> output -> UnfoldM Identity input -> output
- DeferredFolds.UnfoldM: instance GHC.Base.Monad m => Data.Semigroup.Semigroup (DeferredFolds.UnfoldM.UnfoldM m a)
+ DeferredFolds.Unfold: instance Data.Foldable.Foldable DeferredFolds.Unfold.Unfold
+ DeferredFolds.Unfold: instance GHC.Base.Semigroup (DeferredFolds.Unfold.Unfold a)
+ DeferredFolds.UnfoldM: instance Data.Foldable.Foldable (DeferredFolds.UnfoldM.UnfoldM Data.Functor.Identity.Identity)
+ DeferredFolds.UnfoldM: instance GHC.Base.Monad m => GHC.Base.Semigroup (DeferredFolds.UnfoldM.UnfoldM m a)
Files
- deferred-folds.cabal +1/−1
- library/DeferredFolds/Unfold.hs +8/−4
- library/DeferredFolds/UnfoldM.hs +11/−8
deferred-folds.cabal view
@@ -1,7 +1,7 @@ name: deferred-folds version:- 0.4.1+ 0.5 category: Folding synopsis:
library/DeferredFolds/Unfold.hs view
@@ -98,10 +98,14 @@ mempty = empty mappend = (<>) -{-| Perform a strict left fold -}-{-# INLINE foldl' #-}-foldl' :: (output -> input -> output) -> output -> Unfold input -> output-foldl' step init (Unfold run) = run step init+instance Foldable Unfold where+ {-# INLINE foldMap #-}+ foldMap inputMonoid = foldl' step mempty where+ step monoid input = mappend monoid (inputMonoid input)+ foldl = foldl'+ {-# INLINE foldl' #-}+ foldl' step init (Unfold run) = run step init+ {-| Apply a Gonzalez fold -} {-# INLINE fold #-}
library/DeferredFolds/UnfoldM.hs view
@@ -1,7 +1,7 @@ module DeferredFolds.UnfoldM where -import DeferredFolds.Prelude hiding (foldl')+import DeferredFolds.Prelude import qualified DeferredFolds.Prelude as A @@ -47,13 +47,16 @@ mempty = empty mappend = (<>) -{-| Perform a strict left fold -}-{-# INLINE foldl' #-}-foldl' :: (output -> input -> output) -> output -> UnfoldM Identity input -> output-foldl' step init (UnfoldM run) =- runIdentity (run identityStep init)- where- identityStep state input = return (step state input)+instance Foldable (UnfoldM Identity) where+ {-# INLINE foldMap #-}+ foldMap inputMonoid = foldl' step mempty where+ step monoid input = mappend monoid (inputMonoid input)+ foldl = foldl'+ {-# INLINE foldl' #-}+ foldl' step init (UnfoldM run) =+ runIdentity (run identityStep init)+ where+ identityStep state input = return (step state input) {-| Perform a monadic strict left fold -} {-# INLINE foldlM' #-}