{-# Language TypeFamilies, DataKinds, TypeOperators, ConstraintKinds, ExistentialQuantification, KindSignatures, UndecidableInstances #-} module Help where import Data.Kind main :: IO () main = pure () data Entity (cs :: [Type -> Constraint]) = forall a. All cs a => MkEntity a type family All (cs :: [Type -> Constraint]) (a :: Type) :: Constraint where All (c ': cs) a = (c a, All cs a) All '[] a = () class Op1 a where op1 :: a -> Int class Op2 a where op2 :: a -> Char data Foo = Foo { fooInt :: Int, fooChar :: Char } instance Op1 Foo where op1 = fooInt instance Op2 Foo where op2 = fooChar example :: Entity [Op1, Op2] example = MkEntity (Foo 1 'a')