Changes between Version 6 and Version 7 of Language/Variables
 Timestamp:
 06/25/09 01:56:09 (8 years ago)
Legend:
 Unmodified
 Added
 Removed
 Modified

Language/Variables
v6 v7 19 19 [[br]] 20 20 == Name spaces == 21 Each variable lies in a particular names space. There are several name spaces, and the five basic ones are:21 Each variable lies in a particular names space. Variables in the region, effect and closure type name spaces are prefixed with a qualifier. We use % for regions, ! for effects and $ for closures. These symbols are also used for the corresponding region, effect and closure kinds. Variables in the value and value type name spaces do not have qualifiers. 22 22 23 23 '''Namespace''''''qualifier''''''associated kind''''''example''' … … 28 28 Closure types$$$c1, $c2 29 29 30 All variables in the region, effect and closure name spaces are prefixed with a qualifier, which is also the symbol for that kind. 31 32 The general rule is that a variable exists in the name space of its resulting kind. For example: 30 The general rule is that a type variable exists in the name space of its resulting kind. For example: 33 31 34 32 The a in forall a. a > a has kind * and is in name space * (value types) … … 37 35 The variable%r1has kind %and is in name space % (regions) 38 36 39 The exception to this rule type class constructors such as Eq and Mutable. Eq has kind * > + and Mutable has kind % > +, but we put the constructors Eq and Mutable in the * (type) name space instead of making a new name space for +. We follow Haskell in this respect. Note that although Haskell98 doesn't assign kinds to type class constraints, constraints and type constructors are still in the same name space, soyou can't have a type constructor Eq as well as a type class Eq in the same scope.37 The exceptions are type class constructors such as Eq and Mutable. Eq has kind * > + and Mutable has kind % > +. Although the result kind of these constructors is + (witnesses), we put the constructors Eq and Mutable in the * (type) name space instead of making a new name space for +. We follow Haskell in this respect. Note that although Haskell98 doesn't assign kinds to type class constraints, you can't have a type constructor Eq as well as a type class Eq in the same scope. 40 38 41 39 There is also a name space associated with each type. Projection function are added to these name spaces by defining data constructors to have fields, and by explicitly declaring projection dictionaries. For example, if {{{xs}}} has type {{{List Int}}} then the expression {{{xs.length}}} calls the projection function {{{length}}} located in the name space for {{{List Int}}}. If there is no {{{length}}} projection in the {{{List Int}}} name space, but there is in a more general name space such as {{{List a}}}, then that is used instead.