Kind

From HaskellWiki
Revision as of 19:05, 28 September 2017 by Dschrempf (talk | contribs) (Add a more complicated example (StateT))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Wikipedia says, "In type theory, a kind is the type of a type constructor or, less commonly, the type of a higher-order type operator. A kind system is essentially a simply typed lambda calculus 'one level up,' endowed with a primitive type, denoted * and called 'type', which is the kind of any (monomorphic) data type."

Ordinary types, also called monotypes or nullary type constructors, have kind *. Higher order type constructors have kinds of the form P -> Q, where P and Q are kinds. For instance:

Int :: *
Maybe :: * -> *
Maybe Bool :: *
a -> a :: *
[] :: * -> *
(->) :: * -> * -> *

A type with a more complicated kind is the StateT monad transformer

 newtype StateT s m a :: * -> (* -> *) -> * -> *

In Haskell 98, * is the only inhabited kind, that is, all values have types of kind *. GHC introduces another inhabited kind, #, for unlifted types.

See also