Personal tools

Kind

From HaskellWiki

(Difference between revisions)
Jump to: navigation, search
(See also)
(Fixed comma)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Kinds''' classify [[type]]s. Kinds are to types and type-constructors what types are to values.
+
[http://en.wikipedia.org/wiki/Kind_%28type_theory%29 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 have kind <TT>*</TT>. Type constructors have kind <TT>P -> Q</TT>, where <TT>P</TT> and <TT>Q</TT> are kinds. For instance:
 
Ordinary types have kind <TT>*</TT>. Type constructors have kind <TT>P -> Q</TT>, where <TT>P</TT> and <TT>Q</TT> are kinds. For instance:
Line 10: Line 10:
 
  (->) :: * -> * -> *
 
  (->) :: * -> * -> *
  
In Haskell 98, <TT>*</TT> is the only '''inhabited kind''', that is, all values have types of kind <TT>*</TT>. GHC introduces another inhabited kind, <TT>#</TT>, for [[unboxed type]]s.
+
In Haskell 98, <TT>*</TT> is the only '''inhabited kind''', that is, all values have types of kind <TT>*</TT>. GHC introduces another inhabited kind, <TT>#</TT>, for [[unlifted type]]s.
  
 
= See also =
 
= See also =
Line 16: Line 16:
 
* [[GHC/Kinds]]
 
* [[GHC/Kinds]]
 
* [http://hackage.haskell.org/trac/ghc/wiki/IntermediateTypes#KindsareTypes Kinds ?, ??, # and (#)]
 
* [http://hackage.haskell.org/trac/ghc/wiki/IntermediateTypes#KindsareTypes Kinds ?, ??, # and (#)]
 +
* [[Books#Foundations|Pierce, Benjamin. ''Types and Programming Languages'']].
  
 
[[Category:Language]]
 
[[Category:Language]]

Latest revision as of 19:50, 12 September 2016

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 have kind *. Type constructors have kind P -> Q, where P and Q are kinds. For instance:

Int :: *
Maybe :: * -> *
Maybe Bool :: *
a -> 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.

[edit] See also