[Haskell-beginners] IO action on a list of [IO a]
manfred.lotz at arcor.de
Sat Oct 6 20:11:33 CEST 2012
On Sat, 06 Oct 2012 16:56:36 +0200
koomi <koomi at hackerspace-bamberg.de> wrote:
> On 06.10.2012 16:16, Manfred Lotz wrote:
> > Hi all,
> > I want to do an IO action on a list of [IO a] like this:
> > myfor :: (a -> IO () ) -> [IO a] -> IO ()
> > myfor _  = return ()
> > myfor f (x:xs) = do
> > x' <- x
> > f x'
> > myfor f xs
> > Is there a library function doing just this?
> You could do: mapM_ (\x -> x >>= f) xs
Yep, that works nicely. Thanks.
More information about the Beginners