Permitting trailing commas for record syntax ADT declarations

Carter Schonwald carter.schonwald at gmail.com
Wed Sep 24 05:35:13 UTC 2014


i think this should be behind a pragma,

On Tue, Sep 23, 2014 at 5:00 AM, Alexander Berntsen <alexander at plaimi.net>
wrote:

> -----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-----
> _______________________________________________
> ghc-devs mailing list
> ghc-devs at haskell.org
> http://www.haskell.org/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/ghc-devs/attachments/20140924/80ec1113/attachment-0001.html>


More information about the ghc-devs mailing list