Adding replicateM / replicateM_ to Control.Monad

Volker Stolz vs@foldr.org
Thu, 29 Aug 2002 10:12:27 +0200


The following is what I intend to commit. There's a gratuitious
foldM_ as well.

Index: Control/Monad.hs
===================================================================
RCS file: /home/cvs/root/fptools/libraries/base/Control/Monad.hs,v
retrieving revision 1.5
diff -r1.5 Monad.hs
29a30
>     , foldM_        -- :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
43a45,46
>     , replicateM    -- :: (Monad m) => Int -> m a -> m [a]
>     , replicateM_   -- :: (Monad m) => Int -> m a -> m ()
139a143,151
> 
> foldM_            :: (Monad m) => (a -> b -> m a) -> a -> [b] -> m ()
> foldM_ f a xs     = foldM f a xs >> return ()
> 
> replicateM        :: (Monad m) => Int -> m a -> m [a]
> replicateM n x    = sequence (replicate n x)
> 
> replicateM_       :: (Monad m) => Int -> m a -> m ()
> replicateM_ n x   = sequence_ (replicate n x)
-- 
plonk :: m a -> m ()
http://www-i2.informatik.rwth-aachen.de/stolz/ *** PGP *** S/MIME