[Haskell-cafe] Monad explanation

David Menendez dave at zednenem.com
Mon Feb 9 12:41:38 EST 2009

2009/2/9 Gregg Reynolds <dev at mobileink.com>:
> Right; "implementation of IO" means also an implementation for >>=, not just
> the IO operators.  I hadn't thought about that but it's hugely important for
> the exposition of monads and IO.
> "The IO Char indicates that getChar, when invoked, performs some action
> which returns a character." (Gentle Intro, typical of many expositions.)

In this case, I think "invoked" is shorthand for "interpreted by the
runtime system".

> That, plus the form of \x -> putChar x used with >>=, plus the fact that one
> can do getChar at the ghci command line, plus all the other stuff - it all
> adds up to exasperation.

It's worth noting that ghci, unlike Haskell itself, *does* treat IO
specially. It checks the type of the expression you've entered, and
behaves differently depending on whether it's equal to a, IO a, or IO

interp[ e :: IO () ] = e
interp[ e :: IO a ] = e >>= print
interp[ e :: a ] = print e

This is convenient for users, but it has nothing to do with the
semantics of Haskell.

Dave Menendez <dave at zednenem.com>

More information about the Haskell-Cafe mailing list