@@ -56,13 +56,7 @@
5656module Streamly.Internal.Data.Unfold
5757 (
5858 -- * Unfold Type
59− -- |
60− -- A 'Fold' can be run over a seed using the 'unfold' combinator.
61− --
62− -- >>> unfold UF.replicateM (putStrLn "hello") 10
63−
6459 Unfold
65− , unfold
6660
6761 -- * Operations on Input
6862 , close
@@ -113,28 +107,6 @@ import Streamly.Internal.Data.Unfold.Types (Unfold(..))
113107import Streamly.Internal.Data.Fold.Types (Fold(..))
114108import Streamly.Internal.Data.SVar (defState)
115109
116−-------------------------------------------------------------------------------
117−-- Running unfolds
118−-------------------------------------------------------------------------------
119−
120−-- XXX flip the first two arguments to make it similar to unfold i.e. returning
121−-- a -> Stream m b?
122−--
123−-- | Convert an 'Unfold' into a 'Stream' by supplying it a seed.
124−--
125−{-# INLINE_NORMAL unfold #-}
126−unfold :: Monad m => a -> Unfold m a b -> Stream m b
127−unfold seed (Unfold ustep inject) = Stream step Nothing
128− where
129− {-# INLINE_LATE step #-}
130− step _ Nothing = inject seed >>= return . Skip . Just
131− step _ (Just st) = do
132− r <- ustep st
133− return $ case r of
134− Yield x s -> Yield x (Just s)
135− Skip s -> Skip (Just s)
136− Stop -> Stop
137−
138110-------------------------------------------------------------------------------
139111-- Input operations
140112-------------------------------------------------------------------------------