-- Starting point import Data.Kind main :: IO () main = pure () data Entity (c :: Type -> Constraint) = forall a. (c a) => MkEntity a class HasDataID a where getDependencies :: a -> Entity HasDataID instance HasDataID (Entity HasDataID) where getDependencies (MkEntity x) = getDependencies x data Foo = Foo Bar data Bar = Bar instance HasDataID Foo where getDependencies (Foo bar) = MkEntity bar instance HasDataID Bar where getDependencies bar = MkEntity $ Foo bar