Stumpff function

From formulasearchengine
Jump to navigation Jump to search

I'm Robin and was born on 14 August 1971. My hobbies are Disc golf and Hooping.

My web site - http://www.hostgator1centcoupon.info/In the area of mathematical logic and computer science known as 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.

Template:Clarify A kind is sometimes confusingly described as the "type of a (data) type", but this is a triviality,Template:Clarify unless one considers polymorphic types to be data types. Syntactically, it is natural to consider polymorphic types to be type constructors, thus monomorphic types to be nullary type constructors. But all nullary constructors, thus all monomorphic types, have the same, simplest kind; namely .

Since higher-order type operators are uncommon in programming languages, in most programming practice, kinds are used to distinguish between data types and the types of constructors which are used to implement parametric polymorphism. Kinds appear, either explicitly or implicitly, in languages with complexTemplate:Vague type systems, such as Haskell and Scala.[1]

Examples

Kinds in Haskell

(Note: Haskell documentation uses the same arrow for both function types and kinds.)

Haskell's kind system[2] has just two rules:Template:Vague

An inhabited type (as proper types are called in Haskell) is a type which has values. For instance, ignoring type classes which complicate the picture, 4 is a value of type Int, while [1, 2, 3] is a value of type [Int] (list of Ints). Therefore, Int and [Int] have kind , but so does any function type, for instance Int -> Bool or even Int -> Int -> Bool.

A type constructor takes one or more type arguments, and produces a data type when enough arguments are supplied, i.e. it supports partial application thanks to currying.[3][4] This is how Haskell achieves parametric types. For instance, the type [] (list) is a type constructor - it takes a single argument to specify the type of the elements of the list. Hence, [Int] (list of Ints), [Float] (list of Floats) and even [[Int]] (list of lists of Ints) are valid applications of the [] type constructor. Therefore, [] is a type of kind . Because Int has kind , applying it to [] results in [Int], of kind . The 2-tuple constructor (,) has kind , the 3-tuple constructor (,,) has kind and so on.

Kind inference

Haskell does not allow polymorphic kinds. This is in contrast to parametric polymorphism on types, which is supported in Haskell. For instance, in the following example:

data Tree z  = Leaf | Fork (Tree z) (Tree z)

the kind of z could be anything, including , but also etc. Haskell by default will always infer kinds to be , unless the type explicitly indicates otherwise (see below). Therefore the type checker will reject the following use of Tree:

type FunnyTree = Tree []     -- invalid

because the kind of [], does not match the expected kind for z, which is always .

Higher-order type operators are allowed however. For instance:

data App unt z = Z (unt z)

has kind , i.e. unt is expected to be a unary data constructor, which gets applied to its argument, which must be a type, and returns another type.

See also

References

Template:Refbegin

  • 20 year-old Real Estate Agent Rusty from Saint-Paul, has hobbies and interests which includes monopoly, property developers in singapore and poker. Will soon undertake a contiki trip that may include going to the Lower Valley of the Omo.

    My blog: http://www.primaboinca.com/view_profile.php?userid=5889534, chapter 29, "Type Operators and Kinding"

Template:Refend 43 year old Petroleum Engineer Harry from Deep River, usually spends time with hobbies and interests like renting movies, property developers in singapore new condominium and vehicle racing. Constantly enjoys going to destinations like Camino Real de Tierra Adentro.

Template:Data types