[Haskell] How does "do" know when to stop?

Robert Dockins robdockins at fastmail.fm
Thu Feb 15 16:31:40 EST 2007

On Feb 15, 2007, at 4:15 PM, Rob Hoelz wrote:

> When I define a function and I use do to string functions together,  
> how
> does it know when my list of functions has come to an end?  For  
> example:
> foo = do
>     bar
>     baz
>     other_func
> bar = ...
> How does it know to stop at other_func?
> Thanks,
> Rob Hoelz

'do' blocks are subject to the layout rule. See:


The short version is that it notices when a line is less indented,  
and that ends the do block.

Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
           -- TMBG

More information about the Haskell mailing list