[Haskell-cafe] do

Cale Gibbard cgibbard at gmail.com
Mon Dec 3 09:25:06 EST 2007

There are a few rules by which do-syntax is translated into a chain of
bind (>>=) operations:

They are, (approximately):

do { x } = x
do { x ; <stmts> } = x >> do { <stmts> }
do { v <- x ; <stmts> } = x >>= \v -> do { <stmts> }
do { let { <decls> } ; <stmts> } = let <decls> in do { <stmts> }

The meaning of >>= depends on which monad you're using.

I've written a high-level overview about monads, including a section
about do-notation here:

I've also written
which I've found is an approach which is often fairly useful for those
starting out.

If you're just interested in how IO is handled in Haskell, I can offer
a quick blurb about how we think about that here, which I recommend
regardless since it's short:

 - Cale

On 03/12/2007, PR Stanley <prstanley at ntlworld.com> wrote:
> Hi
> I've probably asked about the do construct, if that's the right
> label. Unfortunately I'm still not quite sure of its role and more
> specifically its syntax. Something to do with generators perhaps? A
> description plus some examples would be most gratefully received.
> Thanks, Paul
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe

More information about the Haskell-Cafe mailing list