[Haskell-cafe] layout problem

Christian Maeder maeder at tzi.de
Wed Nov 16 12:14:39 EST 2005

Simon Peyton-Jones wrote:
> Indeed!  I always use braces and semicolons with do-notation.  You are
> free to do so too!  Nothing requires you to use layout. Indeed, you can
> freely mix the two.

I would not recommend braces and semicolons, because these allow a bad 
layout (easy to parse for a compiler, but hard to read for a human), 
unless you invest the time to make a tidy layout despite the braces and 
semicolons. (So why not only make a tidy layout?)

Surely, a different layout may change your semantics (in rare cases). A 
missplaced "_ -> error ..." case usually causes a pattern warning.

> | >> liftIOTrap io =
> | >>     do mx <- liftIO (do x <- io
> | >>                         return (return x)
> | >>                                    `catchError`
> | >>                                    (\e -> return (throwError
> | >>                                                   (fromIOError
> e))))

I'ld rather avoid the infix `catchError' and write:

   liftIO $ catchError
     (do ...
              ) $ \e ->

Cheers Christian

More information about the Haskell-Cafe mailing list