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

Brian Hulley brianh at
Fri Feb 2 23:25:08 EST 2007

Douglas Philips wrote:
> On 2007 Feb 2, at 1:03 PM, Neil Mitchell indited:
>> Personally I'd make the rule that trailing commas are never allowed,
>> anywhere, but I do see an argument for adding them to import lists.
> You just highlighted the inconsistency:
> You refer to "import lists"... you appear to think of the import
> syntax _as a list_,
> and it is precisely that mental processing where the inconsistency
> hits/grates.
> If it is an "import" _list_ it can have trailing commas, but if it is
> some <other> _list_, it can't.
> I don't see the justification for making those two cases different.

I don't either, but I'd agree with Neil that trailing commas shouldn't be 
allowed anywhere, but would reject the argument of allowing them in import 
lists since it just seems to me that this was to save someone making the 
trivial effort to make their code look tidy and complete. Apart from the 
extra possibility for errors (yes I understood that you'd define it to not 
be an error but this doesn't change the fact that for people who always 
wrote their tuples using the normal mathematical convention not using an 
optional trailing comma it would be an error in their code) to go 
undetected, it would just substitute one inconsistency for another: as 
Malcolm pointed out the syntax (,,) represents the constructor for a 3-tuple 

        let a = (x,y,)        -- in your proposal a 2-tuple
        let b = (,,) x y     -- still a 3-tuple with a missing element

I think this would just be far too confusing: the choice to use (,) to 
represent the pair constructor is IMHO too deeply ingrained in existing 
Haskell code to change it to mean a 1-tuple (also do we want to add the 
concept of 1-tuples to the language?). Also, I think in maths the convention 
is to use commas as separators when writing down coordinates etc.

>From a personal aesthetic point of view the appearance of a trailing comma 
is highly irritating to me like passing a shelf in a shop where someone has 
left a book "unsettled" with the cover twisted over the edge at an annoying 
angle and some pages crumpled up, that forces me to stop and fix it... :-)

Regarding import/export lists, in some ways I think the {;} syntax should 
have been used instead then the layout rule could have been applied to good 
effect to get rid of the need for any separators eg:

    module Foo #                            -- # introduces a layout block 
                                Bar #

    import Control.Monad.Trans #

(Though the above is obviously too radical a departure for Haskell')


More information about the Haskell-prime mailing list