Spurious empty context in pattern synonym
Summary
I'm not sure if this is an issue, but I found no one who could answer why () => Show t => t -> Foo
works and Show t => t -> Foo
doesn't. It seems like a bug to me.
Steps to reproduce
{-# LANGUAGE PatternSynonyms #-}
data Foo where
Foo' :: Show t => t -> Foo
-- works
foo :: Show t => t -> Foo
foo x = Foo' x
-- works
foo2 :: () => Show t => t -> Foo
foo2 x = Foo' x
-- works
pattern Foo :: () => Show t => t -> Foo
pattern Foo x <- Foo' x
-- doesn't work ???
pattern Foo2 :: Show t => t -> Foo
pattern Foo2 x <- Foo' x
Actual behaviour
Errors with
test.hs:20:24: error: [GHC-25897]
• Couldn't match expected type ‘t’ with actual type ‘t1’
‘t1’ is a rigid type variable bound by
a pattern with constructor: Foo' :: forall t. Show t => t -> Foo,
in a pattern synonym declaration
at test.hs:20:19-24
‘t’ is a rigid type variable bound by
the signature for pattern synonym ‘Foo2’
at test.hs:19:17-34
• In the declaration for pattern synonym ‘Foo2’
• Relevant bindings include x :: t1 (bound at test.hs:20:24)
Expected behaviour
Show t => t -> Foo
should be a correct type signature for pattern Foo
.
Environment
- GHC version used: 9.6.3
- GHC version used: 9.9.20231121 from nixpkgs (compiled from commit 955520c6).