deferred-folds 0.2.3 → 0.3
raw patch · 2 files changed
+16/−16 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- DeferredFolds.FoldlMView: instance Data.Semigroup.Semigroup (DeferredFolds.FoldlMView.FoldlMView a)
- DeferredFolds.FoldlMView: instance GHC.Base.Alternative DeferredFolds.FoldlMView.FoldlMView
- DeferredFolds.FoldlMView: instance GHC.Base.Applicative DeferredFolds.FoldlMView.FoldlMView
- DeferredFolds.FoldlMView: instance GHC.Base.Functor DeferredFolds.FoldlMView.FoldlMView
- DeferredFolds.FoldlMView: instance GHC.Base.Monad DeferredFolds.FoldlMView.FoldlMView
- DeferredFolds.FoldlMView: instance GHC.Base.MonadPlus DeferredFolds.FoldlMView.FoldlMView
- DeferredFolds.FoldlMView: instance GHC.Base.Monoid (DeferredFolds.FoldlMView.FoldlMView a)
+ DeferredFolds.FoldlMView: instance GHC.Base.Functor m => GHC.Base.Functor (DeferredFolds.FoldlMView.FoldlMView m)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => Data.Semigroup.Semigroup (DeferredFolds.FoldlMView.FoldlMView m a)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => GHC.Base.Alternative (DeferredFolds.FoldlMView.FoldlMView m)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => GHC.Base.Applicative (DeferredFolds.FoldlMView.FoldlMView m)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => GHC.Base.Monad (DeferredFolds.FoldlMView.FoldlMView m)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => GHC.Base.MonadPlus (DeferredFolds.FoldlMView.FoldlMView m)
+ DeferredFolds.FoldlMView: instance GHC.Base.Monad m => GHC.Base.Monoid (DeferredFolds.FoldlMView.FoldlMView m a)
- DeferredFolds.FoldlMView: FoldlMView :: (forall m output. Monad m => (output -> input -> m output) -> output -> m output) -> FoldlMView input
+ DeferredFolds.FoldlMView: FoldlMView :: (forall output. (output -> input -> m output) -> output -> m output) -> FoldlMView m input
- DeferredFolds.FoldlMView: fold :: Fold input output -> FoldlMView input -> output
+ DeferredFolds.FoldlMView: fold :: Fold input output -> FoldlMView Identity input -> output
- DeferredFolds.FoldlMView: foldM :: Monad m => FoldM m input output -> FoldlMView input -> m output
+ DeferredFolds.FoldlMView: foldM :: Monad m => FoldM m input output -> FoldlMView m input -> m output
- DeferredFolds.FoldlMView: foldable :: Foldable foldable => foldable a -> FoldlMView a
+ DeferredFolds.FoldlMView: foldable :: (Monad m, Foldable foldable) => foldable a -> FoldlMView m a
- DeferredFolds.FoldlMView: foldl' :: (output -> input -> output) -> output -> FoldlMView input -> output
+ DeferredFolds.FoldlMView: foldl' :: (output -> input -> output) -> output -> FoldlMView Identity input -> output
- DeferredFolds.FoldlMView: foldlM' :: Monad m => (output -> input -> m output) -> output -> FoldlMView input -> m output
+ DeferredFolds.FoldlMView: foldlM' :: Monad m => (output -> input -> m output) -> output -> FoldlMView m input -> m output
- DeferredFolds.FoldlMView: intsInRange :: Int -> Int -> FoldlMView Int
+ DeferredFolds.FoldlMView: intsInRange :: Monad m => Int -> Int -> FoldlMView m Int
- DeferredFolds.FoldlMView: newtype FoldlMView input
+ DeferredFolds.FoldlMView: newtype FoldlMView m input
Files
- deferred-folds.cabal +1/−1
- library/DeferredFolds/FoldlMView.hs +15/−15
deferred-folds.cabal view
@@ -1,7 +1,7 @@ name: deferred-folds version:- 0.2.3+ 0.3 category: Folding synopsis:
library/DeferredFolds/FoldlMView.hs view
@@ -8,24 +8,24 @@ {-| A monadic variation of "DeferredFolds.FoldView" -}-newtype FoldlMView input =- FoldlMView (forall m output. Monad m => (output -> input -> m output) -> output -> m output)+newtype FoldlMView m input =+ FoldlMView (forall output. (output -> input -> m output) -> output -> m output) -deriving instance Functor FoldlMView+deriving instance Functor m => Functor (FoldlMView m) -instance Applicative FoldlMView where+instance Monad m => Applicative (FoldlMView m) where pure x = FoldlMView (\ step init -> step init x) (<*>) = ap -instance Alternative FoldlMView where+instance Monad m => Alternative (FoldlMView m) where empty = FoldlMView (const return) {-# INLINE (<|>) #-} (<|>) (FoldlMView left) (FoldlMView right) = FoldlMView (\ step init -> left step init >>= right step) -instance Monad FoldlMView where+instance Monad m => Monad (FoldlMView m) where return = pure (>>=) (FoldlMView left) rightK = FoldlMView $ \ step init ->@@ -36,20 +36,20 @@ right step output in left newStep init -instance MonadPlus FoldlMView where+instance Monad m => MonadPlus (FoldlMView m) where mzero = empty mplus = (<|>) -instance Semigroup (FoldlMView a) where+instance Monad m => Semigroup (FoldlMView m a) where (<>) = (<|>) -instance Monoid (FoldlMView a) where+instance Monad m => Monoid (FoldlMView m a) where mempty = empty mappend = (<>) {-| Perform a strict left fold -} {-# INLINE foldl' #-}-foldl' :: (output -> input -> output) -> output -> FoldlMView input -> output+foldl' :: (output -> input -> output) -> output -> FoldlMView Identity input -> output foldl' step init (FoldlMView run) = runIdentity (run identityStep init) where@@ -57,18 +57,18 @@ {-| Perform a monadic strict left fold -} {-# INLINE foldlM' #-}-foldlM' :: Monad m => (output -> input -> m output) -> output -> FoldlMView input -> m output+foldlM' :: Monad m => (output -> input -> m output) -> output -> FoldlMView m input -> m output foldlM' step init (FoldlMView run) = run step init {-| Apply a Gonzalez fold -} {-# INLINE fold #-}-fold :: Fold input output -> FoldlMView input -> output+fold :: Fold input output -> FoldlMView Identity input -> output fold (Fold step init extract) = extract . foldl' step init {-| Apply a monadic Gonzalez fold -} {-# INLINE foldM #-}-foldM :: Monad m => FoldM m input output -> FoldlMView input -> m output+foldM :: Monad m => FoldM m input output -> FoldlMView m input -> m output foldM (FoldM step init extract) view = do initialState <- init@@ -77,11 +77,11 @@ {-| Construct from any foldable -} {-# INLINE foldable #-}-foldable :: Foldable foldable => foldable a -> FoldlMView a+foldable :: (Monad m, Foldable foldable) => foldable a -> FoldlMView m a foldable foldable = FoldlMView (\ step init -> A.foldlM step init foldable) {-| Ints in the specified inclusive range -}-intsInRange :: Int -> Int -> FoldlMView Int+intsInRange :: Monad m => Int -> Int -> FoldlMView m Int intsInRange from to = FoldlMView $ \ step init -> let