Why does `:kind` in the REPL throw error for `data T a f = T (a f)`?

I can kinda help with this. The issue being bumped into here is called “polymorphic kinds” or “polykinds.” Here’s some references on the matter:

If you add a kind annotation to T':

data T' :: (Type -> Type) -> Type -> Type
data T' f a = T' (f a)

then it’ll work (of course that kinda defeats the purpose of asking the REPL to print the kind information).

I think it otherwise could have kind

data T' :: forall k. (k -> Type) -> k -> Type

I can’t do a good job of explaining why T' needs the annotation and others don’t, and I can’t do a good job of explaining what other k’s you could use to do something useful besides Type.

1 Like