I am encountering this error when I try to derive an instance.
Cannot derive well-kinded instance of form ‘HFunctor (ControlFlowCMD ...)’
Class ‘HFunctor’ expects an argument of kind ‘(* -> *, *)
-> * -> *’
• In the newtype declaration for ‘ControlFlowCMD’
I am trying to do this:
newtype ControlFlowCMD fs a = ControlFlowCMD (ControlCMD fs a)
deriving HFunctor via (ControlCMD fs a)
You can see the data type and instance I am basing my type on and trying to derive here, on line 278. I am not that used to using deriving via - could anyone explain what this error means and how I would fix it?
The problem was that
(* -> *, *)
or, equivalently,(Type -> Type, Type)
is a kind-level tuple, and one must enable theDataKinds
andPolyKinds
extensions in order to handle it. (I'm not completely sure whyPolyKinds
is needed though; maybe it's to allow more general kind inference.)With datatypes having complex kinds, it's often a good idea to enable
StandaloneKindSignatures
and give the kind signature explicitly: