@@ -110,11 +110,6 @@ module Streamly.Internal.Data.Unfold
118 -- * Unfolds
113 -- * Unfolds
119 -- One to one correspondence with
114 -- One to one correspondence with
120 -- "Streamly.Internal.Data.Stream.IsStream.Generate"
115 -- "Streamly.Internal.Data.Stream.IsStream.Generate"
@@ -190,15 +185,20 @@ module Streamly.Internal.Data.Unfold
190 , discardFirst
185 , discardFirst
191 , discardSecond
186 , discardSecond
194 -- coapply
188 -- coapply
195 -- comonad
189 -- comonad
197 -- ** Mapping on Output
194 -- ** Mapping on Output
200 , mapMWithInput
197 , mapMWithInput
201 , scanlM'
198 , scanlM'
203 -- ** Either Wrapped Input
203 -- ** Either Wrapped Input
@@ -320,16 +320,6 @@ discardSecond = lmap fst
320swap :: Unfold m (a, c) b -> Unfold m (c, a) b
320swap :: Unfold m (a, c) b -> Unfold m (c, a) b
321swap = lmap Tuple.swap
321swap = lmap Tuple.swap
323−-- See StreamD.scanlM' for implementing this.
325−-- | Scan the input of an 'Unfold' to change it in a stateful manner.
328−{-# INLINE_NORMAL lscanlM' #-}
329−lscanlM' :: -- Monad m =>
330− (b -> a -> m b) -> m b -> Unfold m b c -> Unfold m a c
333-------------------------------------------------------------------------------
323-------------------------------------------------------------------------------
334-- Output operations
324-- Output operations
335-------------------------------------------------------------------------------
325-------------------------------------------------------------------------------
@@ -433,15 +423,21 @@ either (Unfold step1 inject1) = Unfold step inject
433 Skip s -> Skip (s, f)
423 Skip s -> Skip (s, f)
434 Stop -> Stop) <$> step1 st
424 Stop -> Stop) <$> step1 st
436−-- See StreamD.scanlM' for implementing this.
426+-- See StreamD.scanOnce for implementing this.
428+-- | Scan the output of an 'Unfold' to change it in a stateful manner.
431+{-# INLINE_NORMAL scan #-}
432+scan :: Fold m b c -> Unfold m a b -> Unfold m a c
438-- | Scan the output of an 'Unfold' to change it in a stateful manner.
435-- | Scan the output of an 'Unfold' to change it in a stateful manner.
440-- /Unimplemented/
437-- /Unimplemented/
441{-# INLINE_NORMAL scanlM' #-}
438{-# INLINE_NORMAL scanlM' #-}
442−scanlM' :: -- Monad m =>
443− (b -> a -> m b) -> m b -> Unfold m c a -> Unfold m c b
439+scanlM' :: Monad m => (b -> a -> m b) -> m b -> Unfold m c a -> Unfold m c b
444−scanlM' = undefined
440+scanlM' f z = scan (FL.foldlM' f z)
446-------------------------------------------------------------------------------
442-------------------------------------------------------------------------------
447-- Convert streams into unfolds
443-- Convert streams into unfolds