@@ -185,6 +185,9 @@ module Streamly.Internal.Data.Fold.Types
185185 , Fold2 (..)
186186 , simplify
187187
188+ -- * Basic Folds
189+ , toList
190+
188191 -- * Generators
189192 , yield
190193 , yieldM
@@ -410,6 +413,23 @@ simplify :: Functor m => Fold2 m c a b -> c -> Fold m a b
410413simplify (Fold2 step inject extract) c =
411414 Fold (\x a -> Partial <$> step x a) (Partial <$> inject c) extract
412415
416+------------------------------------------------------------------------------
417+-- Basic Folds
418+------------------------------------------------------------------------------
419+
420+-- | Folds the input stream to a list.
421+--
422+-- /Warning!/ working on large lists accumulated as buffers in memory could be
423+-- very inefficient, consider using "Streamly.Data.Array.Storable.Foreign"
424+-- instead.
425+--
426+-- @since 0.7.0
427+
428+-- id . (x1 :) . (x2 :) . (x3 :) . ... . (xn :) $ []
429+{-# INLINABLE toList #-}
430+toList :: Monad m => Fold m a [a]
431+toList = mkAccum (\f x -> f . (x :)) id ($ [])
432+
413433------------------------------------------------------------------------------
414434-- Instances
415435------------------------------------------------------------------------------