
That was my suspicion. So, you can't change horses (monads) in mid-stream.
A parallel question:
main = do ... -- in the IO monad
I know I can have other *do*s in main,
if foo
then do
.
.
else do
.
.
but must all these other *do*s also be in the same IO monad? What determines what monad a *do* is "in"? The first line after the *do*?
Thanks for your patience.
Michael
--- On Sun, 8/8/10, Henning Thielemann
How would I print each of these integers, one per line?
[1,2,3,4,5] >>= \x -> ?
You can't do this from inside the List monad, but you can easily do it from outside, since the result of a 'do' block in List monad is just a list. mapM_ print [1..5] or mapM_ print $ do x <- [1..] ... return (x+y+z)