
6 Oct
2012
6 Oct
'12
5:35 p.m.
On Sat, 06 Oct 2012 16:16:18 +0200, Manfred Lotz
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 use this: import Control.Monad myfor :: (a -> IO () ) -> [IO a] -> IO () myfor f (x:xs) = mapM_ (liftM f) xs or this: import Data.Functor myfor :: (a -> IO () ) -> [IO a] -> IO () myfor f (x:xs) = mapM_ (f <$>) xs For a description of liftM see: http://members.chello.nl/hjgtuyl/tourdemonad.html#liftM Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming --