
2009/07/01 Adam Bergmark
* I'm still a little unsure of why mapM_, sequence and the like are necessary, could someone please explain this, or point me somewhere where I can read up on it?
Say we have a list of `IO` actions (type `[IO a]`). We can't run lists directly; the runtime runs `IO` action (type `IO something`). It's easy to do the translation but we'd rather not do it all the time: here's an easy recursive definition of `sequence`: sequence ops = recurse [] ops where recurse acc [ ] = return $ reverse acc recurse acc (op:rest) = do result <- op sequence' (result:acc) rest The other operations are further conveniences that can be built up from `sequence`.
* Why does this problem occur when there is only one action to perform?
Do you close the handle? -- Jason Dusek