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

Brian Hulley brianh at
Fri Feb 2 11:32:25 EST 2007

Douglas Philips wrote:
> What would be the proper way to propose that:
>> ( exp1 , ... , expk ) (tuple, k>=2)
>> [ exp1 , ... , expk ] (list, k>=1)
> be amended to:
>> ( exp1 , ... , expk [ , ] ) (tuple, k>=2)
>> [ exp1 , ... , expk [ , ] ] (list, k>=1)

I think a problem with the above proposal is that by allowing an optional 
trailing comma the compiler can no longer detect as an error the case where 
the programmer has simply just forgotten to fill in the last element of the 
tuple/list. The existing syntax forces the user to do some extra work 
fiddling about with commas but the reward is that the compiler can verify 
that you haven't forgotten the last argument.

About a year ago I proposed (on the cafe) a syntax sugar to avoid commas in 
tuples and lists which made use of the layout rule something like:

    let a = #[            -- introduces new layout block

    let b = #(

As an aside it would also be nice to be able to use layout for function 
arguments as in:

        a <- foo

the general idea being that '#' immediately followed by an identifier (which 
may be qualified) or the symbol '(' or '[' would start a layout block. ('#' 
of course would no longer be able to be used in symbolic identifiers)


More information about the Haskell-prime mailing list