on master help sign in
Change the argument order in "many"
commit7910e05da731ea742840606445546e1ab041a7e5 authorHarendra Kumar <harendra@composewell.com> dateMon 8 Mar 2021, 19:52 (6 years ago) parentd2e3430
2 files changed+8−10
benchmark/Streamly/Benchmark/Data/Fold.hs+1−1 src/Streamly/Internal/Data/Fold/Types.hs+7−9
benchmark/Streamly/Benchmark/Data/Fold.hs+1−1
@@ -88,7 +88,7 @@ takeEndBy_ value = IP.fold (FL.takeEndBy_ (>= value) FL.drain)
8888
8989{-# INLINE many #-}
9090many :: Monad m => SerialT m Int -> m ()
91−many = IP.fold (FL.many FL.drain (FL.take 1 FL.drain))
91+many = IP.fold (FL.many (FL.take 1 FL.drain) FL.drain)
9292
9393{-# INLINE splitAllAny #-}
9494splitAllAny :: Monad m => Int -> SerialT m Int -> m (Bool, Bool)
src/Streamly/Internal/Data/Fold/Types.hs+7−9
@@ -902,9 +902,7 @@ runStep (Fold step initial extract) a = return $ Fold step initial1 extract
902902-- applied to a fold input stream. groupBy et al can be written as terminating
903903-- folds and then we can apply "many" to use those repeatedly on a stream.
904904
905−-- XXXX flip the order of arguments
906−--
907−-- | Collect zero or more applications of a fold. @many collect split@ applies
905+-- | Collect zero or more applications of a fold. @many split collect@ applies
908906-- the @split@ fold repeatedly on the input stream and accumulates zero or more
909907-- fold results using @collect@.
910908--
@@ -915,8 +913,8 @@ runStep (Fold step initial extract) a = return $ Fold step initial1 extract
915913-- /See also: Streamly.Prelude.concatMap, Streamly.Prelude.foldMany/
916914--
917915{-# INLINE many #-}
918−many :: Monad m => Fold m b c -> Fold m a b -> Fold m a c
919−many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
916+many :: Monad m => Fold m a b -> Fold m b c -> Fold m a c
917+many (Fold sstep sinitial sextract) (Fold cstep cinitial cextract) =
920918 Fold step initial extract
921919
922920 where
@@ -966,7 +964,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
966964-- of @n@ items in the input stream and supplies the result to the @collect@
967965-- fold.
968966--
969−-- > chunksOf n split collect = many collect (take n split)
967+-- > chunksOf n split = many (take n split)
970968--
971969-- Stops when @collect@ stops.
972970--
@@ -974,7 +972,7 @@ many (Fold cstep cinitial cextract) (Fold sstep sinitial sextract) =
974972--
975973{-# INLINE chunksOf #-}
976974chunksOf :: Monad m => Int -> Fold m a b -> Fold m b c -> Fold m a c
977−chunksOf n split collect = many collect (take n split)
975+chunksOf n split = many (take n split)
978976
979977-- |
980978--
@@ -1079,10 +1077,10 @@ takeInterval n (Fold step initial done) = Fold step' initial' done'
10791077--
10801078-- @
10811079--
1082−-- > intervalsOf n split collect = many collect (takeInterval n split)
1080+-- > intervalsOf n split = many (takeInterval n split)
10831081--
10841082-- /Pre-release/
10851083--
10861084{-# INLINE intervalsOf #-}
10871085intervalsOf :: MonadAsync m => Double -> Fold m a b -> Fold m b c -> Fold m a c
1088−intervalsOf n split collect = many collect (takeInterval n split)
1086+intervalsOf n split = many (takeInterval n split)