@@ -51,13 +51,17 @@ module Streamly.Internal.Data.Stream.Concurrent
5151 , evalWith
5252 -- Add unfoldrM/iterateM?
5353
54+ -- ** Generate
55+ -- | Uses a single channel to evaluate all actions.
56+ , repeatM
57+ , replicateM
58+
5459 -- ** Map
5560 -- | Uses a single channel to evaluate all actions.
5661 , mapM
5762 , mapMWith
5863 , sequence
5964 , sequenceWith
60− -- Add repeatM/replicateM?
6165
6266 -- ** Combine two
6367 -- | Use a channel for each pair.
@@ -655,6 +659,27 @@ zipWith :: MonadAsync m
655659 => (a -> b -> c) -> Stream m a -> Stream m b -> Stream m c
656660zipWith f = zipWithM (\a b -> return $ f a b)
657661
662+-------------------------------------------------------------------------------
663+-- Generate
664+-------------------------------------------------------------------------------
665+
666+-- |
667+-- >>> repeatM = Concur.sequence . Stream.repeat
668+--
669+-- Generate a stream by repeatedly executing a monadic action forever. The
670+-- number of actions that are executed concurrently is limited by 'maxThreads'.
671+{-# INLINE repeatM #-}
672+repeatM :: MonadAsync m => m a -> Stream m a
673+repeatM = sequence . Stream.repeat
674+
675+-- |
676+-- >>> replicateM n = Concur.sequence . Stream.replicate n
677+--
678+-- Generate a stream by concurrently performing a monadic action @n@ times.
679+{-# INLINE replicateM #-}
680+replicateM :: MonadAsync m => Int -> m a -> Stream m a
681+replicateM n = sequence . Stream.replicate n
682+
658683-------------------------------------------------------------------------------
659684-- Reactive
660685-------------------------------------------------------------------------------