List syntax (was: Re: help from the community?)
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Fri Feb 2 10:55:18 EST 2007
Douglas Philips <dgou at mac.com> 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 you just did. :-) Actually, it would eventually need a
supporter on the committee to add a ticket on the trac/wiki for this.
I believe that ghc at one time did accept any sequence of white-space
separated commas as if they were a single comma, leading to code such as
[ 1 , , 2 , 3 , ]
Whilst programmers might be able to see the "obvious" meaning when it
occurs in list exprs, do stmts, imports, exports, and the like, they
might run into difficulties in the tuple case. For instance,
(1,2,)
has been proposed as syntactic sugar for a tuple-section, meaning
\x-> (1,2,x)
and this would be a perfectly reasonable and intuitive interpretation
IMO. The number of commas is a powerful visual indication of the arity
of the tuple.
More generally, the notation (,,) is already widely used as the name of
both the type- and data- constructor for triples.
Regards,
Malcolm
More information about the Haskell-prime
mailing list