{-# 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 -> Entity [Op1] class Op2 a where op2 :: a -> Char data Foo = Foo Bar data Bar = Bar -- data Foo = Foo { fooInt :: Int, fooChar :: Char } instance Op1 Foo where op1 (Foo bar) = MkEntity bar instance Op1 Bar where op1 bar = MkEntity bar -- instance Op2 Foo where op2 = fooChar instance Op2 Bar where op2 bar = 'A' example :: Entity [Op1] example = MkEntity Bar