@@ -43,11 +43,6 @@ module Streamly.Internal.Data.Stream.IsStream.Eliminate
46− -- * Specific 'Fold's
47− -- XXX Move to Data.Fold?
48− , toStream -- XXX rename to write? buffer?
49− , toStreamRev -- XXX rename to writeRev? bufferRev?
51 -- * Specific Fold Functions
46 -- * Specific Fold Functions
52 -- | Folds as functions of the shape @t m a -> m b@.
47 -- | Folds as functions of the shape @t m a -> m b@.
@@ -111,8 +106,8 @@ module Streamly.Internal.Data.Stream.IsStream.Eliminate
111 -- ** To Containers
106 -- ** To Containers
113 , toListRev
108 , toListRev
114− , toPure -- XXX move toStream to Data.Fold and rename this to toStream?
109+ , toStream
115− , toPureRev
110+ , toStreamRev
117 -- * Concurrent Folds
112 -- * Concurrent Folds
118 , foldAsync
113 , foldAsync
@@ -152,7 +147,6 @@ import Control.Monad.Catch (MonadThrow)
152import Control.Monad.IO.Class (MonadIO(..))
147import Control.Monad.IO.Class (MonadIO(..))
153import Data.Functor.Identity (Identity (..))
148import Data.Functor.Identity (Identity (..))
154import Foreign.Storable (Storable)
149import Foreign.Storable (Storable)
155−import Streamly.Internal.Data.Fold.Types (Fold (..))
156import Streamly.Internal.Data.Parser (Parser (..))
150import Streamly.Internal.Data.Parser (Parser (..))
157import Streamly.Internal.Data.SVar (MonadAsync, defState)
151import Streamly.Internal.Data.SVar (MonadAsync, defState)
158import Streamly.Internal.Data.Stream.IsStream.Common
152import Streamly.Internal.Data.Stream.IsStream.Common
@@ -763,58 +757,29 @@ toHandle h = go
763 yieldk a r = liftIO (IO.hPutStrLn h a) >> go r
757 yieldk a r = liftIO (IO.hPutStrLn h a) >> go r
764 in K.foldStream defState yieldk single stop m1
758 in K.foldStream defState yieldk single stop m1
766−-- XXX rename these to write/writeRev to make the naming consistent with folds
769−-- | A fold that buffers its input to a pure stream.
771−-- /Warning!/ working on large streams accumulated as buffers in memory could
772−-- be very inefficient, consider using "Streamly.Data.Array" instead.
775−{-# INLINE toStream #-}
776−toStream :: Monad m => Fold m a (SerialT Identity a)
777−toStream = FL.mkAccum (\f x -> f . (x `K.cons`)) id ($ K.nil)
779−-- This is more efficient than 'toStream'. toStream is exactly the same as
780−-- reversing the stream after toStreamRev.
782−-- | Buffers the input stream to a pure stream in the reverse order of the
785−-- /Warning!/ working on large streams accumulated as buffers in memory could
786−-- be very inefficient, consider using "Streamly.Data.Array" instead.
790−-- xn : ... : x2 : x1 : []
791−{-# INLINABLE toStreamRev #-}
792−toStreamRev :: Monad m => Fold m a (SerialT Identity a)
793−toStreamRev = FL.mkAccum_ (flip K.cons) K.nil
795-- | Convert a stream to a pure stream.
760-- | Convert a stream to a pure stream.
798−-- toPure = foldr cons nil
763+-- toStream = foldr cons nil
801-- /Internal/
766-- /Internal/
803−{-# INLINE toPure #-}
768+{-# INLINE toStream #-}
804−toPure :: Monad m => SerialT m a -> m (SerialT Identity a)
769+toStream :: Monad m => SerialT m a -> m (SerialT Identity a)
805−toPure = foldr K.cons K.nil
770+toStream = foldr K.cons K.nil
807-- | Convert a stream to a pure stream in reverse order.
772-- | Convert a stream to a pure stream in reverse order.
810−-- toPureRev = foldl' (flip cons) nil
775+-- toStreamRev = foldl' (flip cons) nil
813-- /Internal/
778-- /Internal/
815−{-# INLINE toPureRev #-}
780+{-# INLINE toStreamRev #-}
816−toPureRev :: Monad m => SerialT m a -> m (SerialT Identity a)
781+toStreamRev :: Monad m => SerialT m a -> m (SerialT Identity a)
817−toPureRev = foldl' (flip K.cons) K.nil
782+toStreamRev = foldl' (flip K.cons) K.nil
819------------------------------------------------------------------------------
784------------------------------------------------------------------------------
820-- Concurrent Application
785-- Concurrent Application