Typing pattern synonyms

Sven Panne svenpanne at gmail.com
Wed Sep 30 20:59:52 UTC 2015

2015-09-30 20:10 GMT+02:00 David Feuer <david.feuer at gmail.com>:

> The Eq constraint is needed to support pattern matching, the raison d’être
> of pattern synonyms.
I was just a bit confused by the fact that normally you don't need an 'Eq
a' constraint for pattern matching. But looking at the Haskell report, one
can see that matching against numeric/char/string literals involves (==),

    \x -> case x of 1234 -> undefined :: (Eq a, Num a) => a -> r

This makes sense now, and there is no magic involved. :-]

> I'm pretty sure the reason you need ScopedTypeVariables for your second
> example is that GHC only allows pattern signatures with that extension
> enabled.
My main question is: Why is this the case? Is it really necessary in our
simple example? The GHC docs should probably mention the magic behind this
in the patter synonym section.

> Once upon a time there was a separate PatternSignatures extension, I
> believe, but not any more.
Never heard of that one...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20150930/65c29aa7/attachment.html>

More information about the Glasgow-haskell-users mailing list