[GHC] #3306: Improve syntax for GADT + records
GHC
ghc-devs at haskell.org
Mon Aug 3 11:37:35 UTC 2015
#3306: Improve syntax for GADT + records
-------------------------------------+-------------------------------------
Reporter: simonpj | Owner: simonpj
Type: feature request | Status: closed
Priority: normal | Milestone: 6.12.1
Component: Compiler | Version: 6.10.2
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions:
-------------------------------------+-------------------------------------
Changes (by skvadrik):
* failure: => None/Unknown
Comment:
6 years later: removed deprecated syntax for GADT constuctors.
This allows to get rid of 2 reduce/reduce conflicts in parser. Conflicting
productions were:
{{{
gadt_constr -> con_list '::' sigtype
gadt_constr -> oqtycon '{' fielddecls '}' '::' sigtype
}}}
Recursive inlining of con_list and oqtycon helped reveal the conflict:
{{{
gadt_constr -> '(' CONSYM ')' '::' sigtype
gadt_constr -> '(' CONSYM ')' '{' fielddecls '}' '::' sigtype
}}}
between two types of GADT constructors (second form stands for deprecated
syntax). However, old syntax allowed `oqtycon` in constructor names, while
new syntax allows `con` (which is not the same). There are therefore some
constructor names that cannot be expressed in terms of new syntax (e.g.
`(*)`).
Note that ordinary data constructors are parsed in a different way than
GADTs: types and names are mixed, so names have to be parsed as types and
then converted to names. In GADTs constructor names and types are
separated by `::`, so names can be parsed as just names and not as types.
This results in a difference in the set of names allowed in GADT and
ordinary constructors. See `Note [Parsing data constructors is hard]` and
`Note [Difference in parsing GADT and data constructors]`
Differential Revision: https://phabricator.haskell.org/D1118
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/3306#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list