You can't with what you've got.
In order to use useBar
with foo ~ Foo
you need evidence that (forall x. SingI x => Barable (Foo x))
.
Pattern matching on proveBar
won't work, because by the time you match Dict
, x
is no longer universally qualified; you've constrained x
to be a particular (unspecified) type.
What you really need is to pattern match something of type Dict (forall x. SingI x => Barable (Foo x))
, but this type isn't currently supported by GHC:
• Illegal polymorphic type: forall x. SingI x => Barable (Foo x)
GHC doesn't yet support impredicative polymorphism
• In the type signature: proveBar' :: Dict (forall x. SingI x => Barable (Foo x))
If instead you had evidence of the form
proveBar :: SingIBarable Foo
data SingIBarable foo where
SingIBarable :: (forall x. SingI x => Barable (foo x)) -> SingIBarable foo
Then you'd be able to use useBar
by pattern matching on proveBar
.