@@ -146,6 +146,7 @@ module Streamly.Internal.Data.Fold
148 , distribute
148 , distribute
150 -- * Partitioning
151 -- * Partitioning
@@ -866,6 +867,22 @@ distribute :: Monad m => [Fold m a b] -> Fold m a [b]
866distribute [] = foldNil
867distribute [] = foldNil
867distribute (x:xs) = foldCons x (distribute xs)
868distribute (x:xs) = foldCons x (distribute xs)
870+-- | Like 'distribute' but for folds that return (), this can be more efficient
871+-- than 'distribute' as it does not need to maintain state.
873+{-# INLINE distribute_ #-}
874+distribute_ :: Monad m => [Fold m a ()] -> Fold m a ()
875+distribute_ fs = Fold step initial extract
877+ initial = Prelude.mapM (\(Fold s i e) ->
878+ i >>= \r -> return (Fold s (return r) e)) fs
880+ Prelude.mapM_ (\(Fold s i _) -> i >>= \r -> s r a >> return ()) ss
883+ Prelude.mapM_ (\(Fold _ i e) -> i >>= \r -> e r) ss
869------------------------------------------------------------------------------
886------------------------------------------------------------------------------
870-- Partitioning
887-- Partitioning
871------------------------------------------------------------------------------
888------------------------------------------------------------------------------