@@ -21,16 +21,25 @@
2121--
2222module Streamly.Internal.Data.Stream.Parallel
2323 (
24+ -- * Parallel Stream Type
2425 ParallelT
2526 , Parallel
2627 , parallely
28+
29+ -- * Merge Concurrently
2730 , parallel
2831 , parallelFst
2932 , parallelMin
30− , tapAsync
33+
34+ -- * Evaluate Concurrently
3135 , mkParallel
3236 , applyParallel
3337 , foldParallel
38+
39+ -- * Tap Concurrently
40+ , tapAsync
41+ , distributeAsync_
42+
3443 )
3544where
3645
@@ -386,6 +395,22 @@ tapAsync f m = mkStream $ \st yld sng stp -> do
386395 sv <- newFoldSVar st f
387396 foldStreamShared st yld sng stp (teeToSVar sv m)
388397
398+-- | Concurrently distribute a stream to a collection of fold functions,
399+-- discarding the outputs of the folds.
400+--
401+-- >>> S.drain $ distributeAsync_ [S.mapM_ print, S.mapM_ print] (S.enumerateFromTo 1 2)
402+--
403+-- @
404+-- distributeAsync_ = flip (foldr tapAsync)
405+-- @
406+--
407+-- /Internal/
408+--
409+{-# INLINE distributeAsync_ #-}
410+distributeAsync_ :: (Foldable f, IsStream t, MonadAsync m)
411+ => f (t m a -> m b) -> t m a -> t m a
412+distributeAsync_ = flip (foldr tapAsync)
413+
389414------------------------------------------------------------------------------
390415-- ParallelT
391416------------------------------------------------------------------------------