haskell-suite / haskell-names

Haskell suite library for name resolution
52 stars 17 forks source link

Added pattern synonym #80

Closed mvoidex closed 8 years ago

mvoidex commented 8 years ago

Pattern synonyms were ignored. Now there is new PatSyn value in Symbol. Fields exported as selectors.

phischu commented 8 years ago

Thank you for your contribution! Why the second commit, what was wrong? I am asking because I want to add tests.

mvoidex commented 8 years ago

By first commit only "exporting" was implemented, i.e. PatSyns were processed in getTopDeclSymbols. But names resolving was still incorrent. It's a bit tricky, for example:

pattern Foo x y = Just ([x], Right y)

Here we will have PatSyn _ p r _ (p :: Pat = Foo x y, q :: Pat = Just ([x], Right y)). Here p is Pat and it must bind not only Names (x, y), but even QNames (Foo), which are never binded by default. And q must not bind anything, only try to resolve, therefore Resolvable Pat works different whether it's usual Pat or Pat from PatSyn. And same thing for PatField as part of Pat.

mvoidex commented 8 years ago

I also haven't tested resolving of pattern synonym usage (only in export list and in pattern synonym declaration), so I think I'll add some new commits here when I have time to.

mvoidex commented 8 years ago

Seems ready to merge

mvoidex commented 8 years ago

Thanks :)