concept kind in category haskell

appears as: The kind, kinds, kind, kind, kinds
Haskell in Depth

This is an excerpt from Manning's book Haskell in Depth.

Haskell uses its kind system to tell the lifted types from unlifted ones. The kind * (or it’s synonym, the Type kind) refers to the lifted boxed types only. In fact, it is defined via more general machinery briefly presented as follows:

We’ll meet other kinds besides Type and Constraint later in this chapter. But now let’s answer the final question for this pretty explorational subsection: can we classify kinds? The answer may be a bit surprising. The names Type and Constraint are not available by default, but they can be imported from the Data.Kind module. Let’s find out whether they have type or kind or something else:

ghci> import Data.Kind (Type, Constraint)
ghci> :type Type

<interactive>:1:1: error: Data constructor not in scope: Type
ghci> :kind Type
Type :: Type
ghci> :kind Constraint
Constraint :: Type

So, the Type kind is not defined at term-level (at least for now). As a result, we can’t use :type for it, but it has a kind Type! Same with the Constraint kind. All this means that kinds are nowadays also types and can be classified by kinds. There is ongoing research on unifying types and terms in Haskell so that types could become terms and we could classify them by types. When this is implemented, we would not need kinds anymore and safely forget about them. Funnily, there was a period in GHC history when kinds were classified by sorts (please, don’t ask me about classifying sorts at those times, as there was only one sort, called BOX), but that period is over. Chances are, we will not need kinds in Haskell either in some near future. Figure 11.1 illustrates the current division between terms and types in Haskell with mappings over them.

Figure 11.1. Terms, types and kinds in Haskell
terms types