Hi,

I'm working on adding type signatures to pattern synonyms. The syntax I'm after would look something like, e.g.:

pattern (Eq b) => P Int (Bool, b) (f [a]) :: (Show a) => Maybe [a]

My problem is with parsing the two contexts. I wrote the parser in the following way, which I felt natural (actions omitted for brevity)

pattern_synonym_sig :: { LSig RdrName }
        : 'pattern' patsyn_context patsyn_stuff '::' patsyn_context type

patsyn_stuff :: { Located (Located RdrName, HsPatSynDetails (LHsType RdrName)) }
        : constr_stuff

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

However, this doesn't work, no matter if those contexts are present or not. If I remove both contexts from the rules, i.e. if I replace pattern_synonym_sig with

        : 'pattern' patsyn_stuff '::' type

then parsing succeeds when there are no contexts on either side. I've also tried

        : 'pattern' patsyn_stuff '::' ctype

with the intention of recovering the required context from the ctype (and I could do similar tricks to get the provided context from the patsyn_stuff by using a modified version of constr_stuff); however, even that doesn't work as I expected it, i.e. with this latter version, this:

pattern Single a :: (Eq a) => [a]

fails with a parse error on "::".

Can someone help me out here please?

Thanks,
        Gergo
_______________________________________________
ghc-devs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/ghc-devs

Reply via email to