
On 10/12/2013 12:11, Dr. ERDI Gergo wrote:
On Mon, 9 Dec 2013, Simon Marlow wrote:
Is Haddock a part of GHC? I don't know. If it's not, then whatever parser it's using will have to be extended to support pattern synonyms.
Haddock uses GHC's parser, but it will need to be taught about pattern synonyms and how to render them in documentation.
OK, I'll add pattern synonym support for Haddock. We don't really have a surface syntax for pattern types (yet?), so for now I'll just use this format:
pattern P :: b -> a -> T a; requires (Num a); provides (Eq b)
Right, I'm not suggesting that we should break the abstraction, but I think it would be really nice if there was a way to say "the following 3 patterns are exhaustive", perhaps in a pragma.
One of the things that we ought to be able to do with this extension is to provide abstract datatypes with pattern matching support. The only thing missing is support for exhaustive pattern matches. F# active patterns has it!
This should be something orthogonal to pattern synonyms that supports regular view patterns as well.
I disagree - dealing with this in the context of pattern synonyms is much easier. You just need some way to declare a set of pattern synonym constructors that together constitute an exhaustive set. There's no good way to "name" a view pattern for this purpose. <perhaps slightly controversial> Besides, I think that once pattern synonyms are in, the main use case for view patterns will be in defining interesting pattern synonyms. And I'd rather use ViewPatternsAlternative for that purpose, because it's a more natural generalisation of pattern guards. Cheers, Simon