[Haskell-cafe] Pattern synonyms and explicit forall.
coot at coot.me
coot at coot.me
Sat Sep 18 11:40:19 UTC 2021
Consider the following existential type:
```
data Some where
Some :: a -> Some
```
The following (bidirectional) pattern synonym is accepted:
```
pattern Any :: a -> Some
pattern Any a = Some a
```
However using an explicit `forall` results in a type error:
```
pattern Any :: forall a. a -> Some
pattern Any a = Some
```
```
Patterns.hs:63:23: error:
• Couldn't match expected type ‘a’ with actual type ‘a1’
‘a1’ is a rigid type variable bound by
a pattern with constructor: Some :: forall a. a -> Some,
in a pattern synonym declaration
at Patterns.hs:63:18-23
‘a’ is a rigid type variable bound by
the signature for pattern synonym ‘Any’
at Patterns.hs:62:23
• In the declaration for pattern synonym ‘Any’
• Relevant bindings include a :: a1 (bound at Patterns.hs:63:23)
|
63 | pattern Any a <- Some a
| ^
```
This is indpendent whether `ExplicitForAll` or `ScopedTypedVariables` extensions are enabled or not.
Is there a way around it, or is this a missing feature?
Best regards,
Marcin Szamotulski
Sent with ProtonMail Secure Email.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 509 bytes
Desc: OpenPGP digital signature
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20210918/c7fd9443/attachment.sig>
More information about the Haskell-Cafe
mailing list