[Haskell-cafe] do... error

Felipe Lessa felipe.lessa at gmail.com
Sat Dec 8 21:59:26 EST 2007

On Dec 9, 2007 12:42 AM, Brandon S. Allbery KF8NH <allbery at ece.cmu.edu> wrote:
> I neglected to say the proper indentation:
>    test  = do x <- item
>               item      -- note, indented to match the token after
> the "do"
>               y <- item
>               return (x,y)

That is the best thing to do. If you don't like the identation rule,
you may also use explicit semicolons as in

test = do {x <- item;
           y <- item;
           return (x,y)}

or maybe

test = do {x <- item; item; y <- item; return (x,y)}

or even

test = do { x  <-
 item;         item
                     ; y <- item ; return

Of course, in the last example you lost all the legibility of your
code, but it compiles =).



More information about the Haskell-Cafe mailing list