{-# LANGUAGE DataKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE PolyKinds #-} module M where import Data.Kind data MsgDef = MsgDoThis type family Msg c -- where Msg X = MsgDef -- as a closed tyfam, it always works type instance Msg X = MsgDef -- as an open tyfam, it depends on the location of 'data X' -- data X -- if you uncomment this definition of X, it compiles type family FromPat c :: Msg c data X -- if you uncomment this definition of X, it fails type instance FromPat X = MsgDoThis