Help needed: parsing pattern synonym contexts

Dr. ERDI Gergo gergo at erdi.hu
Wed Jun 25 13:20:08 UTC 2014


On Tue, 24 Jun 2014, Simon Peyton Jones wrote:

> In the latter case, what happened to the shift/reduce and reduce/reduce 
> errors reported by Happy?  Esp the latter.  If you are getting more you 
> need to track them down.

I think I've figured out what might be causing the problem.

First, a couple figures. With these rules:

pattern_synonym_decl
         : 'pattern' con vars0 patsyn_token pat
         | 'pattern' varid conop varid patsyn_token pat

pattern_synonym_sig
         : 'pattern' patsyn_stuff '::' ctype

patsyn_stuff
         : constr_stuff

I'm getting 112 new reduce/reduce conflicts.

If I add the context like you recommended:

pattern_synonym_sig
         : 'pattern' patsyn_context patsyn_stuff '::' ctype

patsyn_context :: { LHsContext RdrName }
         : forall
         | forall context '=>'


then I get 54 new shift/reduce conflicts and no (new) reduce/reduce 
conflicts.

My feeling is the problem is that patterns don't need any special 
parentheses around type annotations, which means the following is a legal 
pattern synonym definition:

pattern Single x = [x] :: [Int]

and I think that the difference (the '=' or '<-') is too 'deep' between 
this and something like

pattern Single a :: [a]

Unfortunately, I still have no idea how to solve this problem...


More information about the ghc-devs mailing list