{-# language TypeFamilies, UndecidableInstances #-} import GHC.Generics data TNothing = TNothing data TJust a = TJust a type family Merge a b where Merge TNothing x = x Merge (TJust x) TNothing = TJust x class Something tag f where something :: f p -> tag -- Apparently Merge can't be used on the right side, like this: -- instance (Something tagF f, Something tagG g) => Something (Merge tagF tagG) (f :*: g) where instance (Something tagF f, Something tagG g, tag ~ Merge tagF tagG) => Something tag (f :*: g) where something = undefined