{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE PolyKinds #-} module M where import Data.Kind import GHC.TypeLits data Msgx = MsgDoThis | MsgDoThat Type type family Msg c type instance Msg X = Msgx data X -- if you uncomment this definition of X, it compiles type family FromPat c :: Maybe (Msg c) -- data X -- if you uncomment this definition of X, it fails type instance FromPat X = 'Just (MsgDoThis :: Msg X)