on master help sign in
Rename fold constructors in Data.Fold #1016
f203fa8Ranjeet Kumar Ranjan
src/Streamly/Data/Fold.hs+3−3
@@ -119,9 +119,9 @@ module Streamly.Data.Fold
119 Fold -- (..)
119 Fold -- (..)
120
120
121 -- * Constructors
121 -- * Constructors
122− , mkFoldl
122+ , foldl'
123− , mkFoldlM
123+ , foldlM'
124− , mkFoldr
124+ , foldr
125
125
126 -- * Folds
126 -- * Folds
127 -- ** Accumulators
127 -- ** Accumulators
src/Streamly/Internal/Data/Array/Foreign/Mut/Type.hs+1−1
@@ -895,7 +895,7 @@ toArrayMinChunk :: forall m a. (MonadIO m, Storable a)
895 => Int -> Int -> Fold m a (Array a)
895 => Int -> Int -> Fold m a (Array a)
896-- toArrayMinChunk n = FL.rmapM spliceArrays $ toArraysOf n
896-- toArrayMinChunk n = FL.rmapM spliceArrays $ toArraysOf n
897toArrayMinChunk alignSize elemCount =
897toArrayMinChunk alignSize elemCount =
898− FL.rmapM extract $ FL.mkFoldlM step initial
898+ FL.rmapM extract $ FL.foldlM' step initial
899
899
900 where
900 where
901
901
src/Streamly/Internal/Data/Array/Prim/MutTypesInclude.hs+2−2
@@ -137,7 +137,7 @@ shrinkArray (Array arr#) (I# n#) =
137-- /Pre-release/
137-- /Pre-release/
138{-# INLINE_NORMAL write #-}
138{-# INLINE_NORMAL write #-}
139write :: (MonadIO m, Prim a) => Fold m a (Array a)
139write :: (MonadIO m, Prim a) => Fold m a (Array a)
140−write = FL.rmapM extract $ FL.mkFoldlM step initial
140+write = FL.rmapM extract $ FL.foldlM' step initial
141
141
142 where
142 where
143
143
@@ -193,7 +193,7 @@ data ArrayUnsafe a = ArrayUnsafe
193-- /Pre-release/
193-- /Pre-release/
194{-# INLINE_NORMAL writeNUnsafe #-}
194{-# INLINE_NORMAL writeNUnsafe #-}
195writeNUnsafe :: (MonadIO m, Prim a) => Int -> Fold m a (Array a)
195writeNUnsafe :: (MonadIO m, Prim a) => Int -> Fold m a (Array a)
196−writeNUnsafe n = FL.rmapM extract $ FL.mkFoldlM step initial
196+writeNUnsafe n = FL.rmapM extract $ FL.foldlM' step initial
197
197
198 where
198 where
199
199
src/Streamly/Internal/Data/Fold.hs+28−28
@@ -19,11 +19,11 @@ module Streamly.Internal.Data.Fold
19 , Fold (..)
19 , Fold (..)
20
20
21 -- * Constructors
21 -- * Constructors
22− , mkFoldl
22+ , foldl'
23− , mkFoldlM
23+ , foldlM'
24− , mkFoldl1
24+ , foldl1
25− , mkFoldr
25+ , foldr
26− , mkFoldrM
26+ , foldrM
27 , mkFold
27 , mkFold
28 , mkFold_
28 , mkFold_
29 , mkFoldM
29 , mkFoldM
@@ -259,8 +259,8 @@ import qualified Streamly.Internal.Data.Stream.StreamK as K
259import qualified Prelude
259import qualified Prelude
260
260
261import Prelude hiding
261import Prelude hiding
262− ( filter, drop, dropWhile, take, takeWhile, zipWith
262+ ( filter, foldl1, drop, dropWhile, take, takeWhile, zipWith
263− , foldl, map, mapM_, sequence, all, any, sum, product, elem
263+ , foldl, foldr, map, mapM_, sequence, all, any, sum, product, elem
264 , notElem, maximum, minimum, head, last, tail, length, null
264 , notElem, maximum, minimum, head, last, tail, length, null
265 , reverse, iterate, init, and, or, lookup, (!!)
265 , reverse, iterate, init, and, or, lookup, (!!)
266 , scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip
266 , scanl, scanl1, replicate, concatMap, mconcat, foldMap, unzip
@@ -410,7 +410,7 @@ drainBy2 f = Fold2 (const (void . f)) (\_ -> return ()) return
410-- @since 0.7.0
410-- @since 0.7.0
411{-# INLINABLE last #-}
411{-# INLINABLE last #-}
412last :: Monad m => Fold m a (Maybe a)
412last :: Monad m => Fold m a (Maybe a)
413−last = mkFoldl1 (\_ x -> x)
413+last = foldl1 (\_ x -> x)
414
414
415------------------------------------------------------------------------------
415------------------------------------------------------------------------------
416-- To Summary
416-- To Summary
@@ -423,7 +423,7 @@ last = mkFoldl1 (\_ x -> x)
423-- /Pre-release/
423-- /Pre-release/
424{-# INLINE genericLength #-}
424{-# INLINE genericLength #-}
425genericLength :: (Monad m, Num b) => Fold m a b
425genericLength :: (Monad m, Num b) => Fold m a b
426−genericLength = mkFoldl (\n _ -> n + 1) 0
426+genericLength = foldl' (\n _ -> n + 1) 0
427
427
428-- | Determine the length of the input stream.
428-- | Determine the length of the input stream.
429--
429--
@@ -443,7 +443,7 @@ length = genericLength
443-- @since 0.7.0
443-- @since 0.7.0
444{-# INLINE sum #-}
444{-# INLINE sum #-}
445sum :: (Monad m, Num a) => Fold m a a
445sum :: (Monad m, Num a) => Fold m a a
446−sum = mkFoldl (+) 0
446+sum = foldl' (+) 0
447
447
448-- | Determine the product of all elements of a stream of numbers. Returns
448-- | Determine the product of all elements of a stream of numbers. Returns
449-- multiplicative identity (@1@) when the stream is empty. The fold terminates
449-- multiplicative identity (@1@) when the stream is empty. The fold terminates
@@ -474,7 +474,7 @@ product = mkFold_ step (Partial 1)
474-- @since 0.7.0
474-- @since 0.7.0
475{-# INLINE maximumBy #-}
475{-# INLINE maximumBy #-}
476maximumBy :: Monad m => (a -> a -> Ordering) -> Fold m a (Maybe a)
476maximumBy :: Monad m => (a -> a -> Ordering) -> Fold m a (Maybe a)
477−maximumBy cmp = mkFoldl1 max'
477+maximumBy cmp = foldl1 max'
478
478
479 where
479 where
480
480
@@ -495,14 +495,14 @@ maximumBy cmp = mkFoldl1 max'
495-- @since 0.7.0
495-- @since 0.7.0
496{-# INLINE maximum #-}
496{-# INLINE maximum #-}
497maximum :: (Monad m, Ord a) => Fold m a (Maybe a)
497maximum :: (Monad m, Ord a) => Fold m a (Maybe a)
498−maximum = mkFoldl1 max
498+maximum = foldl1 max
499
499
500-- | Computes the minimum element with respect to the given comparison function
500-- | Computes the minimum element with respect to the given comparison function
501--
501--
502-- @since 0.7.0
502-- @since 0.7.0
503{-# INLINE minimumBy #-}
503{-# INLINE minimumBy #-}
504minimumBy :: Monad m => (a -> a -> Ordering) -> Fold m a (Maybe a)
504minimumBy :: Monad m => (a -> a -> Ordering) -> Fold m a (Maybe a)
505−minimumBy cmp = mkFoldl1 min'
505+minimumBy cmp = foldl1 min'
506
506
507 where
507 where
508
508
@@ -523,7 +523,7 @@ minimumBy cmp = mkFoldl1 min'
523-- @since 0.7.0
523-- @since 0.7.0
524{-# INLINE minimum #-}
524{-# INLINE minimum #-}
525minimum :: (Monad m, Ord a) => Fold m a (Maybe a)
525minimum :: (Monad m, Ord a) => Fold m a (Maybe a)
526−minimum = mkFoldl1 min
526+minimum = foldl1 min
527
527
528------------------------------------------------------------------------------
528------------------------------------------------------------------------------
529-- To Summary (Statistical)
529-- To Summary (Statistical)
@@ -535,7 +535,7 @@ minimum = mkFoldl1 min
535-- @since 0.7.0
535-- @since 0.7.0
536{-# INLINABLE mean #-}
536{-# INLINABLE mean #-}
537mean :: (Monad m, Fractional a) => Fold m a a
537mean :: (Monad m, Fractional a) => Fold m a a
538−mean = fmap done $ mkFoldl step begin
538+mean = fmap done $ foldl' step begin
539
539
540 where
540 where
541
541
@@ -553,7 +553,7 @@ mean = fmap done $ mkFoldl step begin
553-- @since 0.7.0
553-- @since 0.7.0
554{-# INLINABLE variance #-}
554{-# INLINABLE variance #-}
555variance :: (Monad m, Fractional a) => Fold m a a
555variance :: (Monad m, Fractional a) => Fold m a a
556−variance = fmap done $ mkFoldl step begin
556+variance = fmap done $ foldl' step begin
557
557
558 where
558 where
559
559
@@ -592,7 +592,7 @@ stdDev = sqrt <$> variance
592-- /Pre-release/
592-- /Pre-release/
593{-# INLINABLE rollingHashWithSalt #-}
593{-# INLINABLE rollingHashWithSalt #-}
594rollingHashWithSalt :: (Monad m, Enum a) => Int64 -> Fold m a Int64
594rollingHashWithSalt :: (Monad m, Enum a) => Int64 -> Fold m a Int64
595−rollingHashWithSalt = mkFoldl step
595+rollingHashWithSalt = foldl' step
596
596
597 where
597 where
598
598
@@ -634,13 +634,13 @@ rollingHashFirstN n = take n rollingHash
634-- Sum {getSum = 65}
634-- Sum {getSum = 65}
635--
635--
636-- @
636-- @
637−-- sconcat = Fold.mkFoldl (<>)
637+-- sconcat = Fold.foldl' (<>)
638-- @
638-- @
639--
639--
640-- @since 0.8.0
640-- @since 0.8.0
641{-# INLINE sconcat #-}
641{-# INLINE sconcat #-}
642sconcat :: (Monad m, Semigroup a) => a -> Fold m a a
642sconcat :: (Monad m, Semigroup a) => a -> Fold m a a
643−sconcat = mkFoldl (<>)
643+sconcat = foldl' (<>)
644
644
645-- | Fold an input stream consisting of monoidal elements using 'mappend'
645-- | Fold an input stream consisting of monoidal elements using 'mappend'
646-- and 'mempty'.
646-- and 'mempty'.
@@ -690,7 +690,7 @@ foldMap f = lmap f mconcat
690-- @since 0.7.0
690-- @since 0.7.0
691{-# INLINABLE foldMapM #-}
691{-# INLINABLE foldMapM #-}
692foldMapM :: (Monad m, Monoid b) => (a -> m b) -> Fold m a b
692foldMapM :: (Monad m, Monoid b) => (a -> m b) -> Fold m a b
693−foldMapM act = mkFoldlM step (pure mempty)
693+foldMapM act = foldlM' step (pure mempty)
694
694
695 where
695 where
696
696
@@ -708,7 +708,7 @@ foldMapM act = mkFoldlM step (pure mempty)
708
708
709-- | Buffers the input stream to a list in the reverse order of the input.
709-- | Buffers the input stream to a list in the reverse order of the input.
710--
710--
711−-- > toListRev = Fold.mkFoldl (flip (:)) []
711+-- > toListRev = Fold.foldl' (flip (:)) []
712--
712--
713-- /Warning!/ working on large lists accumulated as buffers in memory could be
713-- /Warning!/ working on large lists accumulated as buffers in memory could be
714-- very inefficient, consider using "Streamly.Array" instead.
714-- very inefficient, consider using "Streamly.Array" instead.
@@ -718,7 +718,7 @@ foldMapM act = mkFoldlM step (pure mempty)
718-- xn : ... : x2 : x1 : []
718-- xn : ... : x2 : x1 : []
719{-# INLINABLE toListRev #-}
719{-# INLINABLE toListRev #-}
720toListRev :: Monad m => Fold m a [a]
720toListRev :: Monad m => Fold m a [a]
721−toListRev = mkFoldl (flip (:)) []
721+toListRev = foldl' (flip (:)) []
722
722
723------------------------------------------------------------------------------
723------------------------------------------------------------------------------
724-- Partial Folds
724-- Partial Folds
@@ -1101,7 +1101,7 @@ tee = teeWith (,)
1101-- @since 0.7.0
1101-- @since 0.7.0
1102{-# INLINE distribute #-}
1102{-# INLINE distribute #-}
1103distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1103distribute :: Monad m => [Fold m a b] -> Fold m a [b]
1104−distribute = foldr (teeWith (:)) (yield [])
1104+distribute = Prelude.foldr (teeWith (:)) (yield [])
1105
1105
1106------------------------------------------------------------------------------
1106------------------------------------------------------------------------------
1107-- Partitioning
1107-- Partitioning
@@ -1495,7 +1495,7 @@ demuxDefault = demuxDefaultWith id
1495{-# INLINE classifyWith #-}
1495{-# INLINE classifyWith #-}
1496classifyWith :: (Monad m, Ord k) => (a -> k) -> Fold m a b -> Fold m a (Map k b)
1496classifyWith :: (Monad m, Ord k) => (a -> k) -> Fold m a b -> Fold m a (Map k b)
1497classifyWith f (Fold step1 initial1 extract1) =
1497classifyWith f (Fold step1 initial1 extract1) =
1498− rmapM extract $ mkFoldlM step initial
1498+ rmapM extract $ foldlM' step initial
1499
1499
1500 where
1500 where
1501
1501
@@ -1764,12 +1764,12 @@ chunksBetween _low _high _f1 _f2 = undefined
1764-- /Warning!/ working on large streams accumulated as buffers in memory could
1764-- /Warning!/ working on large streams accumulated as buffers in memory could
1765-- be very inefficient, consider using "Streamly.Data.Array" instead.
1765-- be very inefficient, consider using "Streamly.Data.Array" instead.
1766--
1766--
1767−-- > toStream = mkFoldr K.cons K.nil
1767+-- > toStream = foldr K.cons K.nil
1768--
1768--
1769-- /Pre-release/
1769-- /Pre-release/
1770{-# INLINE toStream #-}
1770{-# INLINE toStream #-}
1771toStream :: Monad m => Fold m a (SerialT Identity a)
1771toStream :: Monad m => Fold m a (SerialT Identity a)
1772−toStream = mkFoldr K.cons K.nil
1772+toStream = foldr K.cons K.nil
1773
1773
1774-- This is more efficient than 'toStream'. toStream is exactly the same as
1774-- This is more efficient than 'toStream'. toStream is exactly the same as
1775-- reversing the stream after toStreamRev.
1775-- reversing the stream after toStreamRev.
@@ -1777,7 +1777,7 @@ toStream = mkFoldr K.cons K.nil
1777-- | Buffers the input stream to a pure stream in the reverse order of the
1777-- | Buffers the input stream to a pure stream in the reverse order of the
1778-- input.
1778-- input.
1779--
1779--
1780−-- > toStreamRev = mkFoldl (flip K.cons) K.nil
1780+-- > toStreamRev = foldl' (flip K.cons) K.nil
1781--
1781--
1782-- /Warning!/ working on large streams accumulated as buffers in memory could
1782-- /Warning!/ working on large streams accumulated as buffers in memory could
1783-- be very inefficient, consider using "Streamly.Data.Array" instead.
1783-- be very inefficient, consider using "Streamly.Data.Array" instead.
@@ -1787,4 +1787,4 @@ toStream = mkFoldr K.cons K.nil
1787-- xn : ... : x2 : x1 : []
1787-- xn : ... : x2 : x1 : []
1788{-# INLINABLE toStreamRev #-}
1788{-# INLINABLE toStreamRev #-}
1789toStreamRev :: Monad m => Fold m a (SerialT Identity a)
1789toStreamRev :: Monad m => Fold m a (SerialT Identity a)
1790−toStreamRev = mkFoldl (flip K.cons) K.nil
1790+toStreamRev = foldl' (flip K.cons) K.nil
src/Streamly/Internal/Data/Fold/Type.hs+32−32
@@ -196,11 +196,11 @@ module Streamly.Internal.Data.Fold.Type
196 , Fold (..)
196 , Fold (..)
197
197
198 -- * Constructors
198 -- * Constructors
199− , mkFoldl
199+ , foldl'
200− , mkFoldlM
200+ , foldlM'
201− , mkFoldl1
201+ , foldl1
202− , mkFoldr
202+ , foldr
203− , mkFoldrM
203+ , foldrM
204 , mkFold
204 , mkFold
205 , mkFold_
205 , mkFold_
206 , mkFoldM
206 , mkFoldM
@@ -280,7 +280,7 @@ import Streamly.Internal.Data.Maybe.Strict (Maybe'(..), toMaybe)
280import Streamly.Internal.Data.Tuple.Strict (Tuple'(..), Tuple3'(..))
280import Streamly.Internal.Data.Tuple.Strict (Tuple'(..), Tuple3'(..))
281import Streamly.Internal.Data.SVar (MonadAsync)
281import Streamly.Internal.Data.SVar (MonadAsync)
282
282
283−import Prelude hiding (concatMap, filter, map, take)
283+import Prelude hiding (concatMap, filter, foldl1, foldr, map, take)
284
284
285-- $setup
285-- $setup
286-- >>> :m
286-- >>> :m
@@ -397,22 +397,22 @@ rmapM f (Fold step initial extract) = Fold step1 initial1 (extract >=> f)
397-- the accumulator.
397-- the accumulator.
398--
398--
399-- If your 'Fold' returns only 'Partial' (i.e. never returns a 'Done') then you
399-- If your 'Fold' returns only 'Partial' (i.e. never returns a 'Done') then you
400−-- can use @mkFoldl*@ constructors.
400+-- can use @foldl'*@ constructors.
401--
401--
402-- A fold with an extract function can be expressed using fmap:
402-- A fold with an extract function can be expressed using fmap:
403--
403--
404-- @
404-- @
405-- mkfoldlx :: Monad m => (s -> a -> s) -> s -> (s -> b) -> Fold m a b
405-- mkfoldlx :: Monad m => (s -> a -> s) -> s -> (s -> b) -> Fold m a b
406−-- mkfoldlx step initial extract = fmap extract (mkFoldl step initial)
406+-- mkfoldlx step initial extract = fmap extract (foldl' step initial)
407-- @
407-- @
408--
408--
409-- See also: "Streamly.Prelude.foldl'"
409-- See also: "Streamly.Prelude.foldl'"
410--
410--
411-- @since 0.8.0
411-- @since 0.8.0
412--
412--
413−{-# INLINE mkFoldl #-}
413+{-# INLINE foldl' #-}
414−mkFoldl :: Monad m => (b -> a -> b) -> b -> Fold m a b
414+foldl' :: Monad m => (b -> a -> b) -> b -> Fold m a b
415−mkFoldl step initial =
415+foldl' step initial =
416 Fold
416 Fold
417 (\s a -> return $ Partial $ step s a)
417 (\s a -> return $ Partial $ step s a)
418 (return (Partial initial))
418 (return (Partial initial))
@@ -425,16 +425,16 @@ mkFoldl step initial =
425--
425--
426-- @
426-- @
427-- mkFoldlxM :: Functor m => (s -> a -> m s) -> m s -> (s -> m b) -> Fold m a b
427-- mkFoldlxM :: Functor m => (s -> a -> m s) -> m s -> (s -> m b) -> Fold m a b
428−-- mkFoldlxM step initial extract = rmapM extract (mkFoldlM step initial)
428+-- mkFoldlxM step initial extract = rmapM extract (foldlM' step initial)
429-- @
429-- @
430--
430--
431-- See also: "Streamly.Prelude.foldlM'"
431-- See also: "Streamly.Prelude.foldlM'"
432--
432--
433-- @since 0.8.0
433-- @since 0.8.0
434--
434--
435−{-# INLINE mkFoldlM #-}
435+{-# INLINE foldlM' #-}
436−mkFoldlM :: Monad m => (b -> a -> m b) -> m b -> Fold m a b
436+foldlM' :: Monad m => (b -> a -> m b) -> m b -> Fold m a b
437−mkFoldlM step initial =
437+foldlM' step initial =
438 Fold (\s a -> Partial <$> step s a) (Partial <$> initial) return
438 Fold (\s a -> Partial <$> step s a) (Partial <$> initial) return
439
439
440-- | Make a strict left fold, for non-empty streams, using first element as the
440-- | Make a strict left fold, for non-empty streams, using first element as the
@@ -443,9 +443,9 @@ mkFoldlM step initial =
443-- See also: "Streamly.Prelude.foldl1'"
443-- See also: "Streamly.Prelude.foldl1'"
444--
444--
445-- /Pre-release/
445-- /Pre-release/
446−{-# INLINE mkFoldl1 #-}
446+{-# INLINE foldl1 #-}
447−mkFoldl1 :: Monad m => (a -> a -> a) -> Fold m a (Maybe a)
447+foldl1 :: Monad m => (a -> a -> a) -> Fold m a (Maybe a)
448−mkFoldl1 step = fmap toMaybe $ mkFoldl step1 Nothing'
448+foldl1 step = fmap toMaybe $ foldl' step1 Nothing'
449
449
450 where
450 where
451
451
@@ -463,31 +463,31 @@ mkFoldl1 step = fmap toMaybe $ mkFoldl step1 Nothing'
463--
463--
464-- For example,
464-- For example,
465--
465--
466−-- > toList = mkFoldr (:) []
466+-- > toList = foldr (:) []
467--
467--
468-- See also: "Streamly.Prelude.foldr"
468-- See also: "Streamly.Prelude.foldr"
469--
469--
470-- @since 0.8.0
470-- @since 0.8.0
471−{-# INLINE mkFoldr #-}
471+{-# INLINE foldr #-}
472−mkFoldr :: Monad m => (a -> b -> b) -> b -> Fold m a b
472+foldr :: Monad m => (a -> b -> b) -> b -> Fold m a b
473−mkFoldr g z = fmap ($ z) $ mkFoldl (\f x -> f . g x) id
473+foldr g z = fmap ($ z) $ foldl' (\f x -> f . g x) id
474
474
475-- XXX we have not seen any use of this yet, not releasing until we have a use
475-- XXX we have not seen any use of this yet, not releasing until we have a use
476-- case.
476-- case.
477--
477--
478−-- | Like 'mkFoldr' but with a monadic step function.
478+-- | Like 'foldr' but with a monadic step function.
479--
479--
480-- For example,
480-- For example,
481--
481--
482−-- > toList = mkFoldrM (\a xs -> return $ a : xs) (return [])
482+-- > toList = foldrM (\a xs -> return $ a : xs) (return [])
483--
483--
484-- See also: "Streamly.Prelude.foldrM"
484-- See also: "Streamly.Prelude.foldrM"
485--
485--
486-- /Pre-release/
486-- /Pre-release/
487−{-# INLINE mkFoldrM #-}
487+{-# INLINE foldrM #-}
488−mkFoldrM :: Monad m => (a -> b -> m b) -> m b -> Fold m a b
488+foldrM :: Monad m => (a -> b -> m b) -> m b -> Fold m a b
489−mkFoldrM g z =
489+foldrM g z =
490− rmapM (z >>=) $ mkFoldlM (\f x -> return $ g x >=> f) (return return)
490+ rmapM (z >>=) $ foldlM' (\f x -> return $ g x >=> f) (return return)
491
491
492------------------------------------------------------------------------------
492------------------------------------------------------------------------------
493-- General fold constructors
493-- General fold constructors
@@ -498,7 +498,7 @@ mkFoldrM g z =
498--
498--
499-- mkFold :: Monad m => (s -> a -> Step s b) -> Step s b -> Fold m a b
499-- mkFold :: Monad m => (s -> a -> Step s b) -> Step s b -> Fold m a b
500--
500--
501−-- Then similar to mkFoldl and mkFoldr we can just fmap extract on it to extend
501+-- Then similar to foldl' and foldr we can just fmap extract on it to extend
502-- it to the version where an 'extract' function is required. Or do we even
502-- it to the version where an 'extract' function is required. Or do we even
503-- need that?
503-- need that?
504--
504--
@@ -586,7 +586,7 @@ simplify (Fold2 step inject extract) c =
586-- @since 0.7.0
586-- @since 0.7.0
587{-# INLINABLE drain #-}
587{-# INLINABLE drain #-}
588drain :: Monad m => Fold m a ()
588drain :: Monad m => Fold m a ()
589−drain = mkFoldl (\_ _ -> ()) ()
589+drain = foldl' (\_ _ -> ()) ()
590
590
591-- | Folds the input stream to a list.
591-- | Folds the input stream to a list.
592--
592--
@@ -594,12 +594,12 @@ drain = mkFoldl (\_ _ -> ()) ()
594-- very inefficient, consider using "Streamly.Data.Array.Foreign"
594-- very inefficient, consider using "Streamly.Data.Array.Foreign"
595-- instead.
595-- instead.
596--
596--
597−-- > toList = mkFoldr (:) []
597+-- > toList = foldr (:) []
598--
598--
599-- @since 0.7.0
599-- @since 0.7.0
600{-# INLINABLE toList #-}
600{-# INLINABLE toList #-}
601toList :: Monad m => Fold m a [a]
601toList :: Monad m => Fold m a [a]
602−toList = mkFoldr (:) []
602+toList = foldr (:) []
603
603
604------------------------------------------------------------------------------
604------------------------------------------------------------------------------
605-- Instances
605-- Instances
test/lib/Streamly/Test/Prelude/Common.hs+1−1
@@ -1165,7 +1165,7 @@ transformCombineOpsCommon constr desc eq t = do
1165 monadicIO $ do
1165 monadicIO $ do
1166 cref <- run $ newIORef 0
1166 cref <- run $ newIORef 0
1167 let fldstp _ e = modifyIORef' cref (e +)
1167 let fldstp _ e = modifyIORef' cref (e +)
1168− sumfoldinref = FL.mkFoldlM fldstp (return ())
1168+ sumfoldinref = FL.foldlM' fldstp (return ())
1169 op = S.tap sumfoldinref . S.mapM (\x -> return (x+1))
1169 op = S.tap sumfoldinref . S.mapM (\x -> return (x+1))
1170 listOp = fmap (+1)
1170 listOp = fmap (+1)
1171 stream <- run ((S.toList . t) $ op (constr a <> constr b))
1171 stream <- run ((S.toList . t) $ op (constr a <> constr b))