Stumpff function: Difference between revisions

From formulasearchengine
Jump to navigation Jump to search
en>Teapeat
category:orbits
 
en>Addbot
m Bot: Migrating 1 interwiki links, now provided by Wikidata on d:q3075207
 
Line 1: Line 1:
Hello! <br>I'm English female :D. <br>I really love CSI!<br><br>Feel free to surf to my website - [http://tinyurl.com/m79kb5w http://tinyurl.com/m3ha2dn]
 
{{Confusing|date=August 2013}}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 <math>*</math> and called "type", which is the kind of any ([[parametric polymorphism|monomorphic]]) [[data type]].
 
{{Clarify|date=May 2011}}
A kind is sometimes confusingly described as the "type of a [[data type|(data) type]]", but this is a triviality,{{Clarify|date=September 2013}} unless one considers [[parametric polymorphism|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 <math>*</math>.
 
Since higher-order type operators are uncommon in [[programming language]]s, 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 complex{{Vague|date=August 2009}}<!-- have to check Scala, but I bet it allows parametric polymorphism --> type systems, such as [[Haskell (programming language)|Haskell]] and [[Scala (programming language)|Scala]].<ref name="higherkinds">[http://adriaanm.github.com/files/higher.pdf Generic of a Higher Kind]</ref>
 
== Examples ==
 
* <math>*</math>, pronounced "type", is the kind of all [[data type]]s seen as [[nullary]] type constructors, and also called proper types in this context. This normally includes function types in [[functional programming language]]s.
* <math>* \rightarrow *</math> is the kind of a [[unary]] [[type constructor]], e.g. of a [[list type]] constructor.
* <math>* \rightarrow * \rightarrow *</math> is the kind of a [[wiktionary:binary|binary]] type constructor (via [[currying]]), e.g. of a [[pair type]] constructor, and also that of a [[function type]] constructor (not to be confused with the result of its application, which itself is a function type, thus of kind *)
* <math>(* \rightarrow *) \rightarrow *</math> is the kind of a higher-order type operator from unary type constructors to proper types. See Pierce (2002), chapter 32 for an application.
 
== Kinds in Haskell ==
(''Note'': Haskell documentation uses the same arrow for both function types and kinds.)
 
[[Haskell (programming language)|Haskell]]'s kind system<ref name="haskell98">[http://www.haskell.org/onlinereport/decls.html#sect4.1.1 Kinds - The Haskell 98 Report]</ref> has just two rules:{{Vague|date=August 2009}}<!--does this mean it prohibits higher order type operators? I can't tell from the report. -->
 
* <math>*</math>, pronounced "type" is the kind of all [[data type]]s.
* <math>k_1 \rightarrow k_2</math> is the kind of a [[unary]] [[type constructor]], which takes a type of kind <math>k_1</math> and produces a type of kind <math>k_2</math>.
 
An inhabited type (as proper types are called in Haskell) is a type which has values. For instance, ignoring [[type class]]es which complicate the picture, <code>4</code> is a value of type <code>Int</code>, while <code>[1, 2, 3]</code> is a value of type <code>[Int]</code> (list of Ints). Therefore, <code>Int</code> and <code>[Int]</code> have kind <math>*</math>, but so does any function type, for instance <code>Int -> Bool</code> or even <code>Int -> Int -> Bool</code>.
 
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.<ref name=haskell-2010>{{cite web|title=Chapter 4 Declarations and Binding|url=http://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-65017x3|work=Haskell 2010 Language Report|accessdate=23 July 2012}}</ref><ref>{{cite web|last=Miran|first=Lipovača|title=Learn You a Haskell for Great Good!|url=http://learnyouahaskell.com/making-our-own-types-and-typeclasses|work=Making Our Own Types and Typeclasses|accessdate=23 July 2012}}</ref> This is how Haskell achieves parametric types. For instance, the type <code>[]</code> (list) is a type constructor - it takes a single argument to specify the type of the elements of the list. Hence, <code>[Int]</code> (list of Ints), <code>[Float]</code> (list of Floats) and even <code>[&#91;Int&#93;]</code> (list of lists of Ints) are valid applications of the <code>[]</code> type constructor. Therefore, <code>[]</code> is a type of kind <math>* \rightarrow *</math>. Because <code>Int</code> has kind <math>*</math>, applying it to <code>[]</code> results in <code>[Int]</code>, of kind <math>*</math>. The 2-[[tuple]] constructor <code>(,)</code> has kind <math>* \rightarrow * \rightarrow *</math>, the 3-tuple constructor <code>(,,)</code> has kind <math>* \rightarrow * \rightarrow * \rightarrow *</math> and so on.
 
<!-- needs rewriting to say what it really wants to  say, that is how kind inference is performed, but note that no kind polymorphism is allowed, so it's not quite the same.
The way kinds govern types is analogous to the way types govern values. If an expression <math>f</math> has type <math>t_1 \to t_2</math> (that is, it is a function which accepts a type <math>t_1</math> and produces a type <math>t_2</math>), and <math>x</math> has type <math>t_1</math>, then the result of the function application <math>f \ x</math> has type <math>t_2</math>. Simlarly if an expression <math>t_1</math> has kind <math>k_1 \rightarrow k_2</math>, and type <math>t_2</math> has kind <math>k_1</math>, then the result of the type application <math>t_1 \ t_2</math> has kind <math>k_2</math>. -->
=== Kind inference ===
 
Haskell does not allow [[polymorphic kind]]s. This is in contrast to [[parametric polymorphism]] on types, which is supported in Haskell.  For instance, in the following example:
 
<source lang=haskell>
data Tree z  = Leaf | Fork (Tree z) (Tree z)
</source>
 
the kind of <code>z</code> could be anything, including <math>*</math>, but also <math>* \rightarrow *</math> etc. Haskell by default will always infer kinds to be <math>*</math>, unless the type explicitly indicates otherwise (see below). Therefore the type checker will reject the following use of <code>Tree</code>:
<source lang=haskell>
type FunnyTree = Tree []    -- invalid
</source>
 
because the kind of <code>[]</code>, <math>* \rightarrow *</math> does not match the expected kind for <code>z</code>, which is always <math>*</math>.
 
Higher-order type operators are allowed however. For instance:
 
<source lang=haskell>
data App unt z = Z (unt z)
</source>
 
has kind <math>(* \rightarrow *) \rightarrow * \rightarrow *</math>, i.e. <code>unt</code> 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 ==
* [[System F-omega]]
* [[Pure type system]]
 
== References ==
{{Refbegin}}
* {{cite book|last=Pierce|first=Benjamin|title=[[Types and Programming Languages]]|publisher=MIT Press|date=2002|id=ISBN 0-262-16209-1}}, chapter 29, "Type Operators and Kinding"
{{Refend}}
{{Reflist}}
 
{{Data types}}
 
{{DEFAULTSORT:Kind (Type Theory)}}
[[Category:Type theory]]
[[Category:Data types]]

Latest revision as of 22:51, 19 March 2013

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