This problem actually bit me in the ass in production once before. That is not an exciting bug to have.

So I thought, we need to prove that for the type above, s <: r (read as “s is a subtype of r”). How do we express that? How about a type class.

The type-class can be

class Subset sub super

But how to implement it? Well, we need to say that for every field of sub, that field is also a field of super. That’s made easy for us, because HaskellDB already has a HasField field record class for exactly that!