Help needed: parsing pattern synonym contexts

Dr. ERDI Gergo gergo at
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' con vars0 patsyn_token pat
         | 'pattern' varid conop varid patsyn_token pat

         : 'pattern' patsyn_stuff '::' ctype

         : constr_stuff

I'm getting 112 new reduce/reduce conflicts.

If I add the context like you recommended:

         : '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 

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