@@ -427,10 +427,37 @@ either (Unfold step1 inject1) = Unfold step inject
428-- | Scan the output of an 'Unfold' to change it in a stateful manner.
428-- | Scan the output of an 'Unfold' to change it in a stateful manner.
430−-- /Unimplemented/
430+-- /Pre-release/
431{-# INLINE_NORMAL scan #-}
431{-# INLINE_NORMAL scan #-}
432−scan :: Fold m b c -> Unfold m a b -> Unfold m a c
432+scan :: Monad m => Fold m b c -> Unfold m a b -> Unfold m a c
433+scan (Fold stepF initial extract) (Unfold stepU injectU) =
441+ FL.Partial fs1 -> do
443+ return (fs1, Just us)
433−scan = undefined
444+ FL.Done _ -> return (undefined, Nothing)
446+ {-# INLINE_LATE step #-}
447+ step (fs, Just us) = do
453+ FL.Done v -> return $ Yield v (fs, Nothing)
454+ FL.Partial fs1 -> do
456+ return $ Yield v (fs1, Just s)
457+ Skip s -> return $ Skip (fs, Just s)
460+ step (_, Nothing) = return Stop
435-- | Scan the output of an 'Unfold' to change it in a stateful manner.
462-- | Scan the output of an 'Unfold' to change it in a stateful manner.