iteratee 0.8.0.2 → 0.8.0.3
raw patch · 2 files changed
+35/−2 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Data.Iteratee.ListLike: foldM :: (Monad m, ListLike s b, Nullable s) => (a -> b -> m a) -> a -> Iteratee s m a
+ Data.Iteratee.ListLike: mapM_ :: (Monad m, ListLike s el, Nullable s) => (el -> m b) -> Iteratee s m ()
Files
- iteratee.cabal +1/−1
- src/Data/Iteratee/ListLike.hs +34/−1
iteratee.cabal view
@@ -1,5 +1,5 @@ name: iteratee-version: 0.8.0.2+version: 0.8.0.3 synopsis: Iteratee-based I/O description: The Iteratee monad provides strict, safe, and functional I/O. In addition
src/Data/Iteratee/ListLike.hs view
@@ -44,12 +44,15 @@ ,enumPureNChunk -- ** Enumerator Combinators ,enumPair+ -- ** Monadic functions+ ,mapM_+ ,foldM -- * Classes ,module Data.Iteratee.Iteratee ) where -import Prelude hiding (null, head, last, drop, dropWhile, take, break, foldl, foldl1, length, filter, sum, product)+import Prelude hiding (mapM_, null, head, last, drop, dropWhile, take, break, foldl, foldl1, length, filter, sum, product) import qualified Data.ListLike as LL import qualified Data.ListLike.FoldableLL as FLL@@ -562,3 +565,33 @@ on_cont k e = return $ icont k e in runIter iter' idoneM on_cont {-# INLINE enumPureNChunk #-}+++-- ------------------------------------------------------------------------+-- Monadic functions++-- | Map a monadic function over the elements of the stream and ignore the+-- result.+mapM_ :: (Monad m, LL.ListLike s el, Nullable s)+ => (el -> m b)+ -> Iteratee s m ()+mapM_ f = liftI step+ where+ step (Chunk xs) | LL.null xs = mapM_ f+ step (Chunk xs) = lift (LL.mapM_ f xs) >> mapM_ f+ step s@(EOF _) = idone () s+{-# INLINE mapM_ #-}++-- |The analogue of @Control.Monad.foldM@+foldM :: (Monad m, LL.ListLike s b, Nullable s)+ => (a -> b -> m a)+ -> a+ -> Iteratee s m a+foldM f e = liftI step+ where+ step (Chunk xs) | LL.null xs = liftI step+ step (Chunk xs) = do+ x <- lift $ f e (LL.head xs)+ joinIM $ enumPure1Chunk (LL.tail xs) (foldM f x)+ step (EOF _) = return e+{-# INLINE foldM #-}