[Haskell-cafe] Comma in the front

Brian Hulley brianh at metamilk.com
Fri Jul 14 20:48:14 EDT 2006


Tim Docker wrote:
> These layouts feel a bit artificial to me. I am quite partial to
> python's
> list syntax - a trailing comma is optional. meaning you can write
>
>     [
>        a,
>        b,
>        c,
>     ]
>
> I'm surprised this approach isn't more widespread - Are there reasons
> why
> haskell syntax could not/should not be defined this way?

I think this would be confusing because it looks like a syntax error - the 
last element is missing. The advantage of just having comma as a separator 
is that it allows syntax errors to be detected, whereas making it optional 
would mean one less error is detected at compile time.

I'll take this opportunity to re-present my hyper-cool syntax proposal for 
lists ;-) :

    #[
        a
        b
        c

No need for commas or a closing ] because we could just use layout!

Regards, Brian.
-- 
Logic empowers us and Love gives us purpose.
Yet still phantoms restless for eras long past,
congealed in the present in unthought forms,
strive mightily unseen to destroy us.

http://www.metamilk.com 



More information about the Haskell-Cafe mailing list