On Wed, 15 Jul 2009 13:51:02 -0700
David Leimbach <leim...@gmail.com> wrote:

> On Wed, Jul 15, 2009 at 1:42 PM, Noah Evans <noah.ev...@gmail.com> wrote:
> 
> > http://9fans.net/archive/2008/05/6
> 
> 
> Haskell *will* tell you errors that don't make any sense (at least GHC
> errors) when you don't have things like this done properly

The linked post pointed out there are times when barely-visible errors are not 
caught and go on to cause big problems. That's pretty nasty.

> 
> do x <- foo
> y <- bar
> 
> the y <- bar must be directly under the x on the previous line or it's a
> syntax error, and the error you get from GHC is "the last statement of a do
> construct must be an expression"

Huh, so this Haskell syntax actually prevents you from indenting something that 
would be indented in any other language. Okay...

> 
> Luckilly Haskell will let you ignore "layout" and do the following:
> 
> do { x <- foo
> ; y <- bar }
> 
> However, I don't see enough of this style code to feel comfortable writing
> anything I'd plan to share with anyone and expect them to feel ok reading
> it.

It sure doesn't look comfortable to me. Strange semicolon placement for one 
thing. Do the braces have to be on the same lines as the code like that? Could 
it be written like this?:

do
{
        x <- foo;
        y <- bar
}

That's readable to my eyes, but looks like it may be quite different to the 
first form.


-- 
Ethan Grammatikidis

Those who are slower at parsing information must
necessarily be faster at problem-solving.

Reply via email to