Permitting trailing commas for record syntax ADT declarations

Daniel Trstenjak daniel.trstenjak at gmail.com
Thu Sep 25 11:34:16 UTC 2014


On Thu, Sep 25, 2014 at 12:03:13PM +0200, Herbert Valerio Riedel wrote:
> I'd just like to point out, that lists are something that you may want
> to tweak regularily in code (while tuple are rather fixed-size entities whose
> size is extended less frequently)
> 
> Consider the following JSON example:
> 
> foo = object [
>    "key1" .= True,
>    "key2" .= 123,
>    "key3" .= (),
>    ]
> 
> This is code where I often tend to add/remove lines, and ExtraCommas
> would greatly reduce the diff-noise, and which I really miss from
> languages such as Python which allow me to use trailing commas.

One compromise could be, that additional commatas in literal lists
are only allowed at the beginning and at the end.

Then your use case would work and also something like:

   abc = [ 
      -- a
      , a
      -- b
      , b
      -- c
      , c
      ]


I think that are the main uses of additional commatas in literal lists
and I can't see that someone really wants a list literal like '[,3,,4,]',
so wrongly reading it as a list section shouldn't be an issue.


Greetings,
Daniel


More information about the ghc-devs mailing list