List syntax (was: Re: help from the community?)

Jeffrey Yasskin jyasskin at google.com
Tue Feb 6 23:43:55 EST 2007


On 2/5/07, Ulf Norell <ulfn at cs.chalmers.se> wrote:
>
> On Feb 3, 2007, at 6:35 AM, Douglas Philips wrote:
>
> > Well, if we're going to bring personal points of view in, it highly
> > pisses me off that in a construct such as:
> > ( expr ,
> >   expr ,
> >   expr ,
> >   expr ,
> >   expr ,
> > )
> > I have to be vigilant to remove that trailing comma when it is in
> > _no way_ ambiguous.
>
> How about instead writing
>
> ( expr
> , expr
> , expr
> , expr
> , expr
> )
>
> The only extra work is when inserting an element at the beginning,
> but you have the same problem in your example.

That style would be slightly improved by allowing a _leading_ comma:

[
, expr
, expr
, expr
, expr
, expr
]

In the trailing comma style, it looks like:

[
  expr ,
  expr ,
  expr ,
  expr ,
]

Both require a similar amount of extra space, but I've found the
second useful in python lists that change a lot, so I assume I'd find
similar use in Haskell lists. Of course, the layout proposal solves
this problem too, but it feels like a larger change.

Regarding tuples vs. lists, I care a lot less about tuples because
rearranging them usually requires a type change in lots of places, so
fixing a comma is the least of my worries.

Jeffrey Yasskin


More information about the Haskell-prime mailing list