I am trying to find an explanation of the DataKinds extension that will make sense to me having come from only having read Learn You a Haskell. Is there a standard source th
Here is my take:
Consider a length indexed Vector of type:
data Vec n a where
Vnil :: Vec Zero a
Vcons :: a -> Vec n a -> Vec (Succ n) a
data Zero
data Succ a
Here we have a Kind Vec :: * -> * -> *. Since you can represent a zero length Vector of Int by:
Vect Zero Int
You can also declare meaningless types say:
Vect Bool Int
This means we can have untyped functional programming at the type level. Hence we get rid of such ambiguity by introducing data kinds and can have such a kind:
Vec :: Nat -> * -> *
So now our Vec gets a DataKind named Nat which we can declare as:
datakind Nat = Zero | Succ Nat
By introducing a new data kind, no one can declare a meaningless type since Vec now has a more constrained kind signature.