haskell - A better way to map a function that requires IO over a list -


So recently I have a list of strings, and each has to go independently and some IO Function

So basically I have this: OpenOffList :: [string] - & gt; IO () goOverList (x: []) = doStrLn x goOverList (x: xs) = go goLoverList [x] goOverList xs main = myList = ["first", "second", "third"] goOverList myList

My IO is a bit more complex, but it is a summary of this (a function needs to be in the list and IO I was hoping someone could show me how to improve it.

Your < Code> goOverList function almost mapM_ putStrLn . (Just about because mapM_ also works with empty list, while your function is not there).

There is a work that is a -> Returns each item in a list of a with a list of IOB Â of and IO s b s is . mapM _ is the same mapM except that it does not store the results in a list (that is, () like putStrLn does).

This is actually its normal: type in the function a -> Mb where Monad Me , but in this case m is IO .

² Then this is actually the meter.

Comments