So lately I have a list of strings, and need to independently go over each one and perform some IO
function.
So basically what I have is this:
Your goOverList
function is almost equivalent to mapM_ putStrLn
. (Just almost because mapM_
also works with the empty list while your function does not).
mapM is a function that applies a function of type a -> IO b
¹ to each item in a list of a
s and gives you back an IO
² with a list of b
s. mapM_
is the same as mapM
except that it doesn't store the results in a list (which doesn't make sense for actions that return ()
like putStrLn
does).
¹ Actually it's more general than that: The function has type a -> m b
where Monad m
, but in this case m
is IO
.
² Again it's actually m.