@@ -43,11 +43,6 @@ module Streamly.Internal.Data.Stream.IsStream.Eliminate
4343 , foldl1'
4444 , foldlM'
4545
46− -- * Specific 'Fold's
47− -- XXX Move to Data.Fold?
48− , toStream -- XXX rename to write? buffer?
49− , toStreamRev -- XXX rename to writeRev? bufferRev?
50−
5146 -- * Specific Fold Functions
5247 -- | Folds as functions of the shape @t m a -> m b@.
5348 --
@@ -111,8 +106,8 @@ module Streamly.Internal.Data.Stream.IsStream.Eliminate
111106 -- ** To Containers
112107 , toList
113108 , toListRev
114− , toPure -- XXX move toStream to Data.Fold and rename this to toStream?
115− , toPureRev
109+ , toStream
110+ , toStreamRev
116111
117112 -- * Concurrent Folds
118113 , foldAsync
@@ -152,7 +147,6 @@ import Control.Monad.Catch (MonadThrow)
152147import Control.Monad.IO.Class (MonadIO(..))
153148import Data.Functor.Identity (Identity (..))
154149import Foreign.Storable (Storable)
155−import Streamly.Internal.Data.Fold.Types (Fold (..))
156150import Streamly.Internal.Data.Parser (Parser (..))
157151import Streamly.Internal.Data.SVar (MonadAsync, defState)
158152import Streamly.Internal.Data.Stream.IsStream.Common
@@ -763,58 +757,29 @@ toHandle h = go
763757 yieldk a r = liftIO (IO.hPutStrLn h a) >> go r
764758 in K.foldStream defState yieldk single stop m1
765759
766−-- XXX rename these to write/writeRev to make the naming consistent with folds
767−-- in other modules.
768−--
769−-- | A fold that buffers its input to a pure stream.
770−--
771−-- /Warning!/ working on large streams accumulated as buffers in memory could
772−-- be very inefficient, consider using "Streamly.Data.Array" instead.
773−--
774−-- /Internal/
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)
778−
779−-- This is more efficient than 'toStream'. toStream is exactly the same as
780−-- reversing the stream after toStreamRev.
781−--
782−-- | Buffers the input stream to a pure stream in the reverse order of the
783−-- input.
784−--
785−-- /Warning!/ working on large streams accumulated as buffers in memory could
786−-- be very inefficient, consider using "Streamly.Data.Array" instead.
787−--
788−-- /Internal/
789−
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
794−
795760-- | Convert a stream to a pure stream.
796761--
797762-- @
798−-- toPure = foldr cons nil
763+-- toStream = foldr cons nil
799764-- @
800765--
801766-- /Internal/
802767--
803−{-# INLINE toPure #-}
804−toPure :: Monad m => SerialT m a -> m (SerialT Identity a)
805−toPure = foldr K.cons K.nil
768+{-# INLINE toStream #-}
769+toStream :: Monad m => SerialT m a -> m (SerialT Identity a)
770+toStream = foldr K.cons K.nil
806771
807772-- | Convert a stream to a pure stream in reverse order.
808773--
809774-- @
810−-- toPureRev = foldl' (flip cons) nil
775+-- toStreamRev = foldl' (flip cons) nil
811776-- @
812777--
813778-- /Internal/
814779--
815−{-# INLINE toPureRev #-}
816−toPureRev :: Monad m => SerialT m a -> m (SerialT Identity a)
817−toPureRev = foldl' (flip K.cons) K.nil
780+{-# INLINE toStreamRev #-}
781+toStreamRev :: Monad m => SerialT m a -> m (SerialT Identity a)
782+toStreamRev = foldl' (flip K.cons) K.nil
818783
819784------------------------------------------------------------------------------
820785-- Concurrent Application