I had this code:
class SymbolSet tpe where
data Symbol tpe :: *
data SSet tpe where
Identity :: tpe -> SSet tpe
And :: SSet tpe -> Symbol tpe -> SSet tpe
class HasElem a b where
instance (SymbolSet tpe) => HasElem (And (Identity tpe) s) s
instance (HasElem sset s) => HasElem (And sset s) s
which was compiling in GHC-7.4. However on moving to GHC-7.6 it started giving compilation errors:
'And' of tpe `forall tpe. tpe -> Symbol * tpe -> SSet tpe' is not promotable
on digging through the docs, I found a new clause added to "Datatype Promotion" pages in GHC-7.6 vs GHC-7.4
We do not promote datatypes whose constructors are kind polymorphic, involve constraints, or use existential quantification.
My question is:
- What is the rationale behind not promoting such constructors?
- What would be the correct way of doing it?