@@ -55,6 +55,7 @@ module Streamly.Prelude
5555 , iterate
5656 , iterateM
5757 , fromFoldable
58+ , fromFoldableM
5859
5960 -- * Deconstruction
6061 , uncons
@@ -145,6 +146,7 @@ import Streamly.Streams
145146-- | Build a Stream by unfolding pure steps starting from a seed.
146147--
147148-- @since 0.1.0
149+{-# INLINE unfoldr #-}
148150unfoldr :: IsStream t => (b -> Maybe (a, b)) -> b -> t m a
149151unfoldr step = fromStream . go
150152 where
@@ -156,6 +158,7 @@ unfoldr step = fromStream . go
156158-- | Build a Stream by unfolding monadic steps starting from a seed.
157159--
158160-- @since 0.1.0
161+{-# INLINE unfoldrM #-}
159162unfoldrM :: (IsStream t, Monad m) => (b -> m (Maybe (a, b))) -> b -> t m a
160163unfoldrM step = fromStream . go
161164 where
@@ -165,13 +168,20 @@ unfoldrM step = fromStream . go
165168 Nothing -> stp
166169 Just (a, b) -> yld a (go b)
167170
168−-- | Construct a stream from a 'Foldable' container.
171+-- | Construct a stream from a 'Foldable' containing pure values.
169172--
170173-- @since 0.2.0
171174{-# INLINE fromFoldable #-}
172175fromFoldable :: (IsStream t, Foldable f) => f a -> t m a
173176fromFoldable = Prelude.foldr cons nil
174177
178+-- | Construct a stream from a 'Foldable' containing monadic actions.
179+--
180+-- @since 0.3.0
181+{-# INLINE fromFoldableM #-}
182+fromFoldableM :: (IsStream t, Monad m, Foldable f) => f (m a) -> t m a
183+fromFoldableM = Prelude.foldr consM nil
184+
175185-- | Same as 'fromFoldable'.
176186--
177187-- @since 0.1.0
@@ -294,7 +304,8 @@ foldrM step acc m = go (toStream m)
294304-- @since 0.2.0
295305{-# INLINE scanx #-}
296306scanx :: IsStream t => (x -> a -> x) -> x -> (x -> b) -> t m a -> t m b
297−scanx step begin done m = cons (done begin) $ fromStream $ go (toStream m) begin
307+scanx step begin done m =
308+ cons (done begin) $ fromStream $ go (toStream m) begin
298309 where
299310 go m1 !acc = Stream $ \_ stp sng yld ->
300311 let single a = sng (done $ step acc a)