On Sun, 8 Aug 2010, michael rice wrote:

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*?

'do' is just syntactic sugar that is expanded to '>>=' and '>>' combinators. Determining the monad is the task of type inference. Since x, y and (if b then x else y) must have the same type, so if they are monadic actions, they are all of the same monad type.
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to