If I have the method:
proveBar :: forall x . SingI x => Dict (Barable (Foo x))
proveBar = ...
Then how do I pass this as the context to:
useBar :: forall foo . (forall x. SingI x => Barable (foo x)) => ...
useBar = ...
binding foo to Foo
?
Dict is defined here https://hackage.haskell.org/package/constraints-0.10.1/docs/Data-Constraint.html#g:2
You can't with what you've got.
In order to use
useBarwithfoo ~ Fooyou need evidence that(forall x. SingI x => Barable (Foo x)).Pattern matching on
proveBarwon't work, because by the time you matchDict,xis no longer universally qualified; you've constrainedxto 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:If instead you had evidence of the form
Then you'd be able to use
useBarby pattern matching onproveBar.