Inconsistent trailing comma in export list and record syntax

Hello, I'm wondering why the trailing comma is allowed in export syntax, but not in record syntax, here an example module Foo ( export1, -- is allowed ) where data Type = Type { record1 :: Foo, -- is not allowed } To me this seems quite inconsistent and sometimes quite frustrating, imagine the case that you want to temporarily remove the last record: data Type = Type { record1 :: Foo, -- record2 :: Bar } this would fail due to an extra comma that has to be commented out. You could of course say that I'm using a bad style, but it remains that it seems to be inconsistent to allow a trailing comma in one place and not in the other. So is there an reason for this? Lars Corbijn

Well, for your example frustration, the leading comma style would sort your problem nicely. As for the particulars… hmm, not sure. I use leading commas for both, so I never really noticed. It may be that since modules simply expose functions to other programs, the form is syntactically irrelevant except when the module is being loaded. I am quite curious about it now, though, so I hope there are some more knowledgeable folks with some input. On Jul 11, 2011, at 4:49 AM, L Corbijn wrote:
Hello,
I'm wondering why the trailing comma is allowed in export syntax, but not in record syntax, here an example module Foo ( export1, -- is allowed ) where
data Type = Type { record1 :: Foo, -- is not allowed }
To me this seems quite inconsistent and sometimes quite frustrating, imagine the case that you want to temporarily remove the last record: data Type = Type { record1 :: Foo, -- record2 :: Bar } this would fail due to an extra comma that has to be commented out.
You could of course say that I'm using a bad style, but it remains that it seems to be inconsistent to allow a trailing comma in one place and not in the other. So is there an reason for this?
Lars Corbijn _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Jul 11, 2011, at 11:42 AM, Jack Henahan wrote:
Well, for your example frustration, the leading comma style would sort your problem nicely. As for the particulars… hmm, not sure. I use leading commas for both, so I never really noticed.
That just shifts the problem, I think? Now you can no longer comment out the first line. -- Sjoerd Visscher

On Mon, Jul 11, 2011 at 11:51 AM, Sjoerd Visscher
On Jul 11, 2011, at 11:42 AM, Jack Henahan wrote:
Well, for your example frustration, the leading comma style would sort your problem nicely. As for the particulars… hmm, not sure. I use leading commas for both, so I never really noticed.
That just shifts the problem, I think? Now you can no longer comment out the first line.
I've found this quite annoying, especially when using CPP to conditionally include something in a list, as it might force you to reorder the list to make the commas appear correctly when the conditional section is enabled/disabled. Johan

That just shifts the problem, I think? Now you can no longer comment out the first line.
If you are using to-end-of-line comments with --, then the likelihood of noticing a leading ( or { on the line being commented, is much greater than the likelihood of noticing a trailing comma on the end of the line _before_ the one you are commenting. Regards, Malcolm

On 11 July 2011 10:49, L Corbijn
You could of course say that I'm using a bad style, but it remains that it seems to be inconsistent to allow a trailing comma in one place and not in the other. So is there an reason for this?
I've also noticed that I can write data X = X deriving Show But not import Prelude hiding print But we can write x :: Foo x => … x :: (Foo x) => … Can write class X But not module X I wouldn't expect that there are particular argued reasons for these inconsistencies. It's difficult to balance a consistent syntax in a language while trying to be convenient. I don't think it matters too much.

Hi, Am Montag, den 11.07.2011, 10:49 +0200 schrieb L Corbijn:
You could of course say that I'm using a bad style, but it remains that it seems to be inconsistent to allow a trailing comma in one place and not in the other. So is there an reason for this?
there is actually a bug report against the ghc package in Debian from a user, requesting a more liberal comma separated list parsing. We did not patch ghc in Debian to that end, though :-) http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511834 Greetings, Joachim -- Joachim "nomeata" Breitner mail@joachim-breitner.de | nomeata@debian.org | GPG: 0x4743206C xmpp: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/

Generally allowing trailing (or leading or repeated) commas would clash with tuple sections. Also the pair constructor "(,)" is a special case. http://www.haskell.org/ghc/docs/7.0.4/html/users_guide/syntax-extns.html#tup... Cheers Christian Am 11.07.2011 12:09, schrieb Joachim Breitner:
Hi,
Am Montag, den 11.07.2011, 10:49 +0200 schrieb L Corbijn:
You could of course say that I'm using a bad style, but it remains that it seems to be inconsistent to allow a trailing comma in one place and not in the other. So is there an reason for this?
there is actually a bug report against the ghc package in Debian from a user, requesting a more liberal comma separated list parsing. We did not patch ghc in Debian to that end, though :-) http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=511834
Greetings, Joachim
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (8)
-
Christian Maeder
-
Christopher Done
-
Jack Henahan
-
Joachim Breitner
-
Johan Tibell
-
L Corbijn
-
Malcolm Wallace
-
Sjoerd Visscher