:: Int -> IO a -> IO [a] -package:ghc-internal

Perform the action in the given number of threads.
Generalized version of replicateConcurrently.
Generalized version of replicateConcurrently.
replicateM n act performs the action act n times, and then returns the list of results.
replicateM n (pure x) == replicate n x

Examples

>>> replicateM 3 getLine
hi
heya
hiya
["hi","heya","hiya"]
>>> import Control.Monad.State

>>> runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1
([1,2,3],4)
replicateM n act performs the action act n times, and then returns the list of results:

Examples

>>> import Control.Monad.State

>>> runState (replicateM 3 $ state $ \s -> (s, s + 1)) 1
([1,2,3],4)
count n p parses n occurrences of p. If n is smaller or equal to zero, the parser equals to pure []. Returns a list of n parsed values.
count = replicateM
See also: skipCount, count'.
count n p parses n occurrences of p. If n is smaller or equal to zero, the parser equals to return []. Returns a list of n values returned by p.
replicateM n act performs the action n times, gathering the results. Using ApplicativeDo: 'replicateM 5 as' can be understood as the do expression
do a1 <- as
a2 <- as
a3 <- as
a4 <- as
a5 <- as
pure [a1,a2,a3,a4,a5]
Note the Applicative constraint.
replicateM n act performs the action n times, gathering the results.
Apply the given action repeatedly, returning every result.
count n p parses n occurrences of p. If n is smaller or equal to zero, the parser equals to return []. Returns a list of n values. See also: skipCount, count'.
Tail recursive version of replicateM
(O(n log n)) resample specialized to IO.
Similar to pooledReplicateConcurrentlyN but with number of threads set from getNumCapabilities. Usually this is useful for CPU bound tasks.
'exactly n p' parses precisely n items, using the parser p, in sequence.
'upto n p' parses n or fewer items, using the parser p, in sequence.
Like replicateM, but executing the action multiple times in parallel.
Perform the action in the given number of threads.
Generates a list of the given length.
O(n) Execute the monadic action the given number of times and store the results in a vector.