Changes between Version 2 and Version 3 of Commentary/Compiler/Kinds
 Timestamp:
 Jun 8, 2012 8:34:46 AM (3 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Commentary/Compiler/Kinds
v2 v3 1 1 = Kinds = 2 2 3 Kinds are represented as types: 3 Kinds classify types. So for example: 4 {{{ 5 Int :: * 6 Int > Int :: * 7 Maybe :: * > * 8 Int# :: # 9 (# Int, Int #) :: # 10 }}} 11 The base kinds are these: 12 * "`*`" is the kind of boxed values. Things like `Int` and `Maybe Float` have kind `*`. 13 * "`#`" is the kind of unboxed values. Things like `Int#` have kind `#`. 14 * With the advent of [wiki:GhcKinds data type promotion and kind polymorphism] we can have a lot more kinds. 15 16 (Unboxed tuples used to have a distinct kind, but in 2012 we combined unboxed tuples with other unboxed values in a single kind "`#`".) 17 18 == Representing kinds == 19 20 Kinds are represented by the data type `Type` (see [wiki:Commentary/Compiler/TypeType]): 4 21 {{{ 5 22 type Kind = Type 6 23 }}} 7 Basic kinds are now24 Basic kinds are 8 25 represented using type constructors, e.g. the kind `*` is represented as 9 26 {{{ … … 28 45 === Kind subtyping === 29 46 47 There is a small amount of subtyping in kinds. Suppose you see `(t1 > t2)`. What kind must `t1` and `t2` have? It could be `*` or `#`. So we have a single kind `OpenKind`, which is a superkind of both, with this simple lattice: 48 30 49 [[Image(https://docs.google.com/drawings/pub?id=1M5yBP8iAWTgqdI3oG1UNnYihVlipnvvk2vLInAFxtNM&w=359&h=229)]] 31 50 32 51 (You can edit this picture [https://docs.google.com/drawings/d/1M5yBP8iAWTgqdI3oG1UNnYihVlipnvvk2vLInAFxtNM/edit?hl=en_GB here].) 33 52 34 * "`*`" is the kind of boxed values. Things like `Int` and `Maybe Float` have kind `*`. 35 36 * "`#`" is the kind of unboxed values. Things like `Int#` have kind `#`. 37 38 * "`(#)`" is the kind of unboxed tuples. Things like `(# Int, Int #)` have kind `(#)`. 39 40 * "`ArgKind`" is the kind of things that can appear as arguments to functions. 41 42 * "`OpenKind`" is the kind of things that can appear as results of functions. 53 * "`OpenKind`" is the kind of things that can appear as argument or result of functions.