In the vinyl library, there is a RecAll type family, which let's us ask that a partially applied constraint is true for every type in a type level list. For example, we can write this:

myShowFunc :: RecAll f rs Show => Rec f rs -> String

And that's all lovely. Now, if we have the constraint RecAll f rs c where c is unknown, and we know the c x entails d x (to borrow language from ekmett's contstraints package), how can we get RecAll f rs d ?

The reason I ask is that I'm working with records in some functions that require satisfying several typeclass constraints. To do this, I am using the :&: combinator from the Control.Constraints.Combine module in the exists package. (Note: the package won't build if you have other things installed because it depends on a super-old version of contravariant . You can just copy the one module I mentioned though.) With this, I can get some really beautiful constraints while minimizing typeclass broilerplate. For example:

RecAll f rs (TypeableKey :&: FromJSON :&: TypeableVal) => Rec f rs -> Value

But, inside the body of this function, I call another function that demands a weaker constraint. It might look like this:

RecAll f rs (TypeableKey :&: TypeableVal) => Rec f rs -> Value

GHC can't see that the second statement follows from the first. I assumed that would be the case. What I can't see is how to prove it for reify it and help GHC out. So far, I've got this:

import Data.Constraint weakenAnd1 :: ((a :&: b) c) :- a c weakenAnd1 = Sub Dict -- not the Dict from vinyl. ekmett's Dict. weakenAnd2 :: ((a :&: b) c) :- b c weakenAnd2 = Sub Dict

These work fine. But this is where I am stuck:

-- The two Proxy args are to stop GHC from complaining about AmbiguousTypes weakenRecAll :: Proxy f -> Proxy rs -> (a c :- b c) -> (RecAll f rs a :- RecAll f rs b) weakenRecAll _ _ (Sub Dict) = Sub Dict

This does not compile. Is anyone aware of a way to get the effect I am looking for. Here are the errors if they are helpful. Also, I have Dict as a qualified import in my actual code, so that's why it mentions Constraint.Dict :