haskell-suite / haskell-src-exts

Manipulating Haskell source: abstract syntax, lexer, parser, and pretty-printer
Other
193 stars 94 forks source link

Parse contexts of GADT records #405

Closed christiaanb closed 6 years ago

christiaanb commented 6 years ago

Fixes #404

Doesn't implement parser for the forall . bit yet; suggestions appreciated.

The reason I didn't add a parser for the forall . bit is:

A) Adding something like:

>       | qcon '::' forall context '{' fielddecls '}' '->' truectype
>                                       {% do { c <- checkUnQual $1;
>                                               ctxt <- checkContext (Just $3) ;
>                                               return [GadtDecl ($1 <> $8 <** [$2,$4,$6,$7] ++ snd $5) c Nothing ctxt (Just (reverse $ fst $5)) $8] } }

severely increases the shift/reduce conflicts to 83; I couldn't find out what the expected norm here is.

B) Whether adding separate fields for TVs and Context to the GadtDecl data type is the desired API, as they are only Just values when we're parsing a GADT record. For normal GADT types, the field are empty as TVs and context are parsed as part of the Type.