Allow extra commas in module declarations or lists?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Allow extra commas in module declarations or lists?

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
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Allow extra commas in module declarations or lists?

migmit-2
I think that's the greatest idea since monads. Seriously.

Отправлено с iPad

> 11 июня 2016 г., в 21:12, Michael Burge <[hidden email]> написал(а):
>
> 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
> [hidden email]
> http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Reply | Threaded
Open this post in threaded view
|

Re: Allow extra commas in module declarations or lists?

Joachim Breitner-2
In reply to this post by Michael Burge
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
  [hidden email]https://www.joachim-breitner.de/
  XMPP: [hidden email] • OpenPGP-Key: 0xF0FBF51F
  Debian Developer: [hidden email]
_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users

signature.asc (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Allow extra commas in module declarations or lists?

Ben Franksen
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

_______________________________________________
Glasgow-haskell-users mailing list
[hidden email]
http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users