@@ -22,25 +22,30 @@ module Streamly.Internal.Data.Stream.Serial
23 -- * Serial appending stream
23 -- * Serial appending stream
25− , StreamT -- deprecated
27 , K.serial
26 , K.serial
28 , serially
27 , serially
30 -- * Serial interleaving stream
29 -- * Serial interleaving stream
31 , WSerialT
30 , WSerialT
32− , InterleavedT -- deprecated
35 , wSerialFst
33 , wSerialFst
36 , wSerialMin
34 , wSerialMin
37− , (<=>) -- deprecated
38 , wSerially
35 , wSerially
39− , interleaving -- deprecated
36+
41 -- * Transformation
40 -- * Transformation
@@ -397,3 +402,32 @@ LIST_INSTANCES(WSerialT)
397NFDATA1_INSTANCE(WSerialT)
402NFDATA1_INSTANCE(WSerialT)
398FOLDABLE_INSTANCE(WSerialT)
403FOLDABLE_INSTANCE(WSerialT)
399TRAVERSABLE_INSTANCE(WSerialT)
404TRAVERSABLE_INSTANCE(WSerialT)
406+------------------------------------------------------------------------------
408+------------------------------------------------------------------------------
410+-- | Build a stream by unfolding a /monadic/ step function starting from a
411+-- seed. The step function returns the next element in the stream and the next
412+-- seed value. When it is done it returns 'Nothing' and the stream ends. For
418+-- then return Nothing
419+-- else print b >> return (Just (b, b + 1))
420+-- in drain $ unfoldrM f 0
431+{-# INLINE unfoldrM #-}
432+unfoldrM :: Monad m => (b -> m (Maybe (a, b))) -> b -> SerialT m a
433+unfoldrM step seed = D.fromStreamD (D.unfoldrM step seed)