conduit 1.2.10 → 1.2.11
raw patch · 4 files changed
+72/−1 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Data.Conduit.Internal.List.Stream: unfoldEitherMS :: Monad m => (b -> m (Either r (a, b))) -> b -> StreamConduitM i a m r
+ Data.Conduit.Internal.List.Stream: unfoldEitherS :: Monad m => (b -> Either r (a, b)) -> b -> StreamConduitM i a m r
+ Data.Conduit.List: unfoldEither :: Monad m => (b -> Either r (a, b)) -> b -> ConduitM i a m r
+ Data.Conduit.List: unfoldEitherM :: Monad m => (b -> m (Either r (a, b))) -> b -> ConduitM i a m r
Files
- ChangeLog.md +4/−0
- Data/Conduit/Internal/List/Stream.hs +26/−0
- Data/Conduit/List.hs +41/−0
- conduit.cabal +1/−1
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.2.11++* Add `unfoldEither` and `unfoldEitherM` to `Data.Conduit.List`+ ## 1.2.10 * Add `PrimMonad` instances for `ConduitM` and `Pipe`
Data/Conduit/Internal/List/Stream.hs view
@@ -23,6 +23,19 @@ Just (x, s') -> Emit s' x {-# INLINE unfoldS #-} +unfoldEitherS :: Monad m+ => (b -> Either r (a, b))+ -> b+ -> StreamConduitM i a m r+unfoldEitherS f s0 _ =+ Stream step (return s0)+ where+ step s = return $+ case f s of+ Left r -> Stop r+ Right (x, s') -> Emit s' x+{-# INLINE unfoldEitherS #-}+ unfoldMS :: Monad m => (b -> m (Maybe (a, b))) -> b@@ -37,6 +50,19 @@ Just (x, s') -> Emit s' x {-# INLINE unfoldMS #-} +unfoldEitherMS :: Monad m+ => (b -> m (Either r (a, b)))+ -> b+ -> StreamConduitM i a m r+unfoldEitherMS f s0 _ =+ Stream step (return s0)+ where+ step s = do+ ms' <- f s+ return $ case ms' of+ Left r -> Stop r+ Right (x, s') -> Emit s' x+{-# INLINE unfoldEitherMS #-} sourceListS :: Monad m => [a] -> StreamProducer m a sourceListS xs0 _ = Stream (return . step) (return xs0)
Data/Conduit/List.hs view
@@ -19,7 +19,9 @@ sourceList , sourceNull , unfold+ , unfoldEither , unfoldM+ , unfoldEitherM , enumFromTo , iterate , replicate@@ -73,6 +75,7 @@ import Prelude ( ($), return, (==), (-), Int , (.), id, Maybe (..), Monad+ , Either (..) , Bool (..) , (>>) , (>>=)@@ -114,6 +117,25 @@ {-# INLINE unfoldC #-} STREAMING(unfold, unfoldC, unfoldS, f x) +-- | Generate a source from a seed value with a return value.+--+-- Subject to fusion+--+-- @since 1.2.11+unfoldEither, unfoldEitherC :: Monad m+ => (b -> Either r (a, b))+ -> b+ -> ConduitM i a m r+unfoldEitherC f =+ go+ where+ go seed =+ case f seed of+ Right (a, seed') -> yield a >> go seed'+ Left r -> return r+{-# INLINE unfoldEitherC #-}+STREAMING(unfoldEither, unfoldEitherC, unfoldEitherS, f x)+ -- | A monadic unfold. -- -- Subject to fusion@@ -132,6 +154,25 @@ Just (a, seed') -> yield a >> go seed' Nothing -> return () STREAMING(unfoldM, unfoldMC, unfoldMS, f seed)++-- | A monadic unfoldEither.+--+-- Subject to fusion+--+-- @since 1.2.11+unfoldEitherM, unfoldEitherMC :: Monad m+ => (b -> m (Either r (a, b)))+ -> b+ -> ConduitM i a m r+unfoldEitherMC f =+ go+ where+ go seed = do+ mres <- lift $ f seed+ case mres of+ Right (a, seed') -> yield a >> go seed'+ Left r -> return r+STREAMING(unfoldEitherM, unfoldEitherMC, unfoldEitherMS, f seed) -- | Yield the values from the list. --
conduit.cabal view
@@ -1,5 +1,5 @@ Name: conduit-Version: 1.2.10+Version: 1.2.11 Synopsis: Streaming data processing library. description: `conduit` is a solution to the streaming data problem, allowing for production,