Typing pattern synonyms

David Feuer david.feuer at gmail.com
Wed Sep 30 18:10:59 UTC 2015


The Eq constraint is needed to support pattern matching, the raison d’être
of pattern synonyms. I'm pretty sure the reason you need
ScopedTypeVariables for your second example is that GHC only allows pattern
signatures with that extension enabled. Once upon a time there was a
separate PatternSignatures extension, I believe, but not any more.
On Sep 30, 2015 2:04 PM, "Sven Panne" <svenpanne at gmail.com> wrote:

> The type of a pattern synonym like
>
>    pattern FOO = 1234
>
> seems to be '(Eq a, Num a) => a', which makes partially makes sense,
> although it's not immediately clear to me where the 'Eq a' part comes from.
> But probably that would be clear if I read the desugaring rules closely
> enough. ;-) My real question is about:
>
>    pattern FOO = 1234 :: Int
>
> This doesn't compile out of the box, GHC seems to require
> ScopedTypeVariables, too:
>
>     Illegal type signature: `Int'
>       Perhaps you intended to use ScopedTypeVariables
>     In a pattern type-signature
>
> Why is this the case? From a user perspective, the error is totally bogus,
> there are no visible type variables at all. Can GHC be fixed to avoid
> enabling ScopedTypeVariables?
>
> Cheers,
>    S.
>
>
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/glasgow-haskell-users/attachments/20150930/c80675c1/attachment.html>


More information about the Glasgow-haskell-users mailing list