[Haskell-cafe] Pattern synonyms and explicit forall.

Anthony Clayden anthony.d.clayden at gmail.com
Sun Sep 19 03:34:29 UTC 2021


Thank you Kai-Oliver.

>        pattern Any2 :: forall . forall a. a -> Some

We're friends here. I think I can share that my reaction was a rather
loud WTF??!!??

And there's not a mention in the docos that this is even a thing. I
feel like dragging whoever's responsible to the headmaster's office.

Ok that seems to work -- in the sense that pattern-matching on it
yields an `x` that's unusable on RHS just as much as the `Any` decl
with implicit `forall`, or with no type signature at all.

What would be useful is to be able to introduce a constraint into the
sig, so I can do something like

>    foo (Any2 x) y = x == y


After playing with it, all I'm getting is weird rejections.

>    pattern Any2 :: forall . forall a. () => (Eq a) => a -> Some


>    * Pattern synonym `Any2' has one argument
>        but its type signature has 1 fewer arrows

I need to put the constraints inside the scope of the `forall a.`. A
single `(Show a) => a -> Some` complains no instance provided.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210919/dbf475b3/attachment.html>


More information about the Haskell-Cafe mailing list