:: Int -> IO a -> IO [a] package:relude

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)