Permitting trailing commas for record syntax ADT declarations
Alexander Berntsen
alexander at plaimi.net
Tue Sep 23 09:00:36 UTC 2014
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
See the diff/excerpt below. If it were a pragma, I think this might get
ugly quick (consider that this patch only adds leading/trailing commas
for record declarations).
If you think I should be changing things elsewhere/employing a different
approach, please let me know. This was just the place that seemed most
relevant to me.
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp
index fcc21e1..a9267bb 100644
- --- a/compiler/parser/Parser.y.pp
+++ b/compiler/parser/Parser.y.pp
@@ -1370,7 +1370,7 @@ constr_stuff :: { Located (Located RdrName, HsConDeclDetails RdrName) }
| btype conop btype { LL ($2, InfixCon $1 $3) }
fielddecls :: { [ConDeclField RdrName] }
- - : {- empty -} { [] }
+ : ',' fielddecls1 { $2 }
| fielddecls1 { $1 }
fielddecls1 :: { [ConDeclField RdrName] }
@@ -1378,6 +1378,7 @@ fielddecls1 :: { [ConDeclField RdrName] }
{ [ addFieldDoc f $4 | f <- $1 ] ++ addFieldDocs $5 $2 }
-- This adds the doc $4 to each field separately
| fielddecl { $1 }
+ | {- empty -} { [] }
fielddecl :: { [ConDeclField RdrName] } -- A list because of f,g :: Int
: maybe_docnext sig_vars '::' ctype maybe_docprev { [ ConDeclField fld $4 ($1 `mplus` $5)
- --
Alexander
alexander at plaimi.net
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iF4EAREIAAYFAlQhNrQACgkQRtClrXBQc7UfPQD/ThiruhidjdSHLBHz/cryR30V
l6SOdJ1ToExAE0Uv1JcA/RmkMOgi69JnfGrM0Fo6JLyXOIekjyuKLnA4Nm6ASQFk
=P5W7
-----END PGP SIGNATURE-----
More information about the ghc-devs
mailing list