Allow extra commas in module declarations or lists?

Some languages like Perl allow you to include additional commas in your lists, so that you can freely reorder them without worrying about adding or removing commas from the last or first item: my @array = ( 1, 2, 3, ); Perl even allows multiple redundant commas everywhere after the first element, which is less useful but has come up on occasion: my @array = (1,,,2,,,,,,,,,3,,,,,); I propose allowing an optional single extra comma at the end in module declarations, record declarations, record constructors, and list constructors: module Example ( module Example, SomeConstructor(..), ) where data SomeConstructor = SomeConstructor { foo :: Int, bar :: Int, } baz :: SomeConstructor -> SomeConstructor baz x = x { foo = 5, bar = 10, } qux :: [ Int ] qux = [ 1, 2, 3, ] What do you think?

I think that's the greatest idea since monads. Seriously. Отправлено с iPad
11 июня 2016 г., в 21:12, Michael Burge
написал(а): Some languages like Perl allow you to include additional commas in your lists, so that you can freely reorder them without worrying about adding or removing commas from the last or first item:
my @array = ( 1, 2, 3, );
Perl even allows multiple redundant commas everywhere after the first element, which is less useful but has come up on occasion: my @array = (1,,,2,,,,,,,,,3,,,,,);
I propose allowing an optional single extra comma at the end in module declarations, record declarations, record constructors, and list constructors:
module Example ( module Example, SomeConstructor(..), ) where
data SomeConstructor = SomeConstructor { foo :: Int, bar :: Int, }
baz :: SomeConstructor -> SomeConstructor baz x = x { foo = 5, bar = 10, }
qux :: [ Int ] qux = [ 1, 2, 3, ]
What do you think? _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

Hi, Am Samstag, den 11.06.2016, 12:12 -0700 schrieb Michael Burge:
What do you think?
For the module header, this is already possible. For the term language, it unfortunately clashes with things like TupleSections. I believe this has been discussed a few times in the past, e.g. https://mail.haskell.org/pipermail/haskell-prime/2013-May/003833.html Greetings, Joachim -- Joachim “nomeata” Breitner mail@joachim-breitner.de • https://www.joachim-breitner.de/ XMPP: nomeata@joachim-breitner.de • OpenPGP-Key: 0xF0FBF51F Debian Developer: nomeata@debian.org

Sorry for late comment. Am 12.06.2016 um 14:24 schrieb Joachim Breitner:
Am Samstag, den 11.06.2016, 12:12 -0700 schrieb Michael Burge: I propose allowing an optional single extra comma at the end in module declarations, record declarations, record constructors, and list constructors:
module Example ( module Example, SomeConstructor(..), ) where
data SomeConstructor = SomeConstructor { foo :: Int, bar :: Int, }
baz :: SomeConstructor -> SomeConstructor baz x = x { foo = 5, bar = 10, }
qux :: [ Int ] qux = [ 1, 2, 3, ]
What do you think?
For the module header, this is already possible.
For the term language, it unfortunately clashes with things like TupleSections.
Tuples haven't been mentioned by the OP. Indeed, extra commas don't make any sense for tuples so let's just forget about them.
I believe this has been discussed a few times in the past, e.g. https://mail.haskell.org/pipermail/haskell-prime/2013-May/003833.html
And, like here, people concentrate on the red herring 'tuple sections'. To repeat (and slightly flesh out) the proposal: Allow an optional single extra comma at the end in: * module import and export lists * record declarations * record constructors * record updates * list constructors I can't see anything problematic with that. Cheers Ben -- "Make it so they have to reboot after every typo." ― Scott Adams
participants (4)
-
Ben Franksen
-
Joachim Breitner
-
Michael Burge
-
MigMit