conduit 1.1.0.2 → 1.1.1
raw patch · 3 files changed
+52/−18 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Conduit.List: mapAccum :: Monad m => (a -> s -> (s, b)) -> s -> ConduitM a b m s
+ Data.Conduit.List: mapAccumM :: Monad m => (a -> s -> m (s, b)) -> s -> ConduitM a b m s
+ Data.Conduit.List: scan :: Monad m => (a -> b -> b) -> b -> ConduitM a b m b
+ Data.Conduit.List: scanM :: Monad m => (a -> b -> m b) -> b -> ConduitM a b m b
Files
- Data/Conduit/List.hs +49/−15
- conduit.cabal +1/−1
- test/main.hs +2/−2
Data/Conduit/List.hs view
@@ -39,6 +39,8 @@ , concatMap , concatMapAccum , scanl+ , scan+ , mapAccum , groupBy , isolate , filter@@ -46,6 +48,8 @@ , mapM , iterM , scanlM+ , scanM+ , mapAccumM , mapMaybeM , mapFoldableM , concatMapM@@ -72,7 +76,7 @@ import qualified Data.Foldable as F import Data.Conduit import qualified Data.Conduit.Internal as CI-import Control.Monad (when, (<=<), liftM)+import Control.Monad (when, (<=<), liftM, void) import Control.Monad.Trans.Class (lift) -- | Generate a source from a seed value.@@ -342,37 +346,67 @@ -- -- Since 0.3.0 concatMapAccum :: Monad m => (a -> accum -> (accum, [b])) -> accum -> Conduit a m b-concatMapAccum f x0 = scanl f x0 =$= concat+concatMapAccum f x0 = void (mapAccum f x0) =$= concat --- | Analog of 'Prelude.scanl' for lists.+-- | Deprecated synonym for @mapAccum@ -- -- Since 1.0.6-scanl :: Monad m => (a -> s -> (s,b)) -> s -> Conduit a m b-scanl f =+scanl :: Monad m => (a -> s -> (s, b)) -> s -> Conduit a m b+scanl f s = void $ mapAccum f s+{-# DEPRECATED scanl "Use mapAccum instead" #-}++-- | Deprecated synonym for @mapAccumM@+--+-- Since 1.0.6+scanlM :: Monad m => (a -> s -> m (s, b)) -> s -> Conduit a m b+scanlM f s = void $ mapAccumM f s+{-# DEPRECATED scanlM "Use mapAccumM instead" #-}++-- | Analog of @mapAccumL@ for lists.+--+-- Since 1.1.1+mapAccum :: Monad m => (a -> s -> (s, b)) -> s -> ConduitM a b m s+mapAccum f = loop where- loop s = await >>= maybe (return ()) go+ loop s = await >>= maybe (return s) go where go a = case f a s of- (s',b) -> yield b >> loop s'+ (s', b) -> yield b >> loop s' --- | Monadic scanl.+-- | Monadic `mapAccum`. ----- Since 1.0.6-scanlM :: Monad m => (a -> s -> m (s,b)) -> s -> Conduit a m b-scanlM f =+-- Since 1.1.1+mapAccumM :: Monad m => (a -> s -> m (s, b)) -> s -> ConduitM a b m s+mapAccumM f = loop where- loop s = await >>= maybe (return ()) go+ loop s = await >>= maybe (return s) go where- go a = do (s',b) <- lift $ f a s- yield b >> loop s'+ go a = do (s', b) <- lift $ f a s+ yield b+ loop s' +-- | Analog of 'Prelude.scanl' for lists.+--+-- Since 1.1.1+scan :: Monad m => (a -> b -> b) -> b -> ConduitM a b m b+scan f =+ mapAccum $ \a b -> let b' = f a b in (b', b')++-- | Monadic @scanl@.+--+-- Since 1.1.1+scanM :: Monad m => (a -> b -> m b) -> b -> ConduitM a b m b+scanM f =+ mapAccumM $ \a b -> do b' <- f a b+ return (b', b')+ -- | 'concatMapM' with an accumulator. -- -- Since 0.3.0 concatMapAccumM :: Monad m => (a -> accum -> m (accum, [b])) -> accum -> Conduit a m b-concatMapAccumM f x0 = scanlM f x0 =$= concat+concatMapAccumM f x0 = void (mapAccumM f x0) =$= concat -- | Generalization of 'mapMaybe' and 'concatMap'. It applies function
conduit.cabal view
@@ -1,5 +1,5 @@ Name: conduit-Version: 1.1.0.2+Version: 1.1.1 Synopsis: Streaming data processing library. Description: @conduit@ is a solution to the streaming data problem, allowing for production, transformation, and consumption of streams of data in constant memory. It is an alternative to lazy I\/O which guarantees deterministic resource handling, and fits in the same general solution space as @enumerator@\/@iteratee@ and @pipes@. For a tutorial, please visit <https://haskell.fpcomplete.com/user/snoyberg/library-documentation/conduit-overview>.
test/main.hs view
@@ -71,7 +71,7 @@ prop "Maybe" $ equivToList (catMaybes . map f :: [Int]->[Int]) (CL.mapFoldable f) - prop "scanl" $ equivToList (tail . scanl (+) 0 :: [Int]->[Int]) (CL.scanl (\a s -> (a+s,a+s)) 0)+ prop "scan" $ equivToList (tail . scanl (+) 0 :: [Int]->[Int]) (void $ CL.scan (+) 0) -- mapFoldableM and scanlM are fully polymorphic in type of monad -- so it suffice to check only with Identity.@@ -82,7 +82,7 @@ prop "Maybe" $ equivToList (catMaybes . map f :: [Int]->[Int]) (CL.mapFoldableM (return . f)) - prop "scanl" $ equivToList (tail . scanl (+) 0 :: [Int]->[Int]) (CL.scanlM (\a s -> return (a+s,a+s)) 0)+ prop "scanM" $ equivToList (tail . scanl (+) 0) (void $ CL.scanM (\a s -> return $ a + s) (0 :: Int)) describe "ResourceT" $ do it "resourceForkIO" $ do