
8 Aug
2010
8 Aug
'10
11:36 a.m.
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.