{-# LANGUAGE MultiParamTypeClasses, DataKinds, FlexibleInstances, UndecidableInstances, TypeOperators #-} import GHC.TypeLits data E1 = E1 data E2 = E2 data P1 = P1 data P2 = P2 class Has en pr instance Has E1 P1 instance Has E1 P2 instance Has E2 P2 instance {-# OVERLAPPABLE #-} TypeError (Text "The entity " :<>: ShowType en :<>: Text " doesn't have the property " :<>: ShowType pr) => Has en pr -- do something useful foo :: Has en pr => en -> pr -> IO () foo _ _ = return () main :: IO () main = foo E2 P1