@@ -6,22 +6,22 @@ title: "Type Lambdas - More Details"
66## Syntax
77
88```
9- Type ::= ... | HkTypeParamClause ‘=>’ Type
9+ Type ::= ... | HkTypeParamClause ‘=>> ’ Type
1010HkTypeParamClause ::= ‘[’ HkTypeParam {‘,’ HkTypeParam} ‘]’
1111HkTypeParam ::= {Annotation} [‘+’ | ‘-’] (Id[HkTypeParamClause] | ‘_’) TypeBounds
1212TypeBounds ::= [‘>:’ Type] [‘<:’ Type]
1313```
1414
1515### Type Checking
1616
17- A type lambda such ` [X] => F[X] ` defines a function from types to types. The parameter(s) may carry bounds and variance annotations.
18- If a parameter is is bounded, as in ` [X >: L <: H] => F[X] ` it is checked that arguments to the parameters conform to the bounds ` L ` and ` H ` .
17+ A type lambda such ` [X] =>> F[X] ` defines a function from types to types. The parameter(s) may carry bounds and variance annotations.
18+ If a parameter is is bounded, as in ` [X >: L <: H] =>> F[X] ` it is checked that arguments to the parameters conform to the bounds ` L ` and ` H ` .
1919Only the upper bound ` H ` can be F-bounded, i.e. ` X ` can appear in it.
2020
2121A variance annotation on a parameter indicates a subtyping relationship on type instances. For instance, given
2222``` scala
23- type TL1 = [+ A ] => F [A ]
24- type TL2 = [- A ] => F [A ]
23+ type TL1 = [+ A ] =>> F [A ]
24+ type TL2 = [- A ] =>> F [A ]
2525```
2626and two types ` S <: T ` , we have
2727``` scala
@@ -37,8 +37,8 @@ It is checked that variance annotations on parameters of type lambdas are respec
3737
3838Assume two type lambdas
3939``` scala
40- type TL1 = [v1 X >: L1 <: U1 ] => R1
41- type TL2 = [v2 X >: L2 <: U2 ] => R2
40+ type TL1 = [v1 X >: L1 <: U1 ] =>> R1
41+ type TL2 = [v2 X >: L2 <: U2 ] =>> R2
4242```
4343where ` v1 ` and ` v2 ` are optional variance annotations: ` + ` , ` - ` , or absent.
4444Then ` TL1 <: TL2 ` , if
@@ -51,7 +51,7 @@ Then `TL1 <: TL2`, if
5151Here we have relied on alpha renaming to bring match the two bound types ` X ` .
5252
5353A partially applied type constructor such as ` List ` is assumed to be equivalent to
54- its eta expansion. I.e, ` List = [+X] => List[X] ` . This allows type constructors
54+ its eta expansion. I.e, ` List = [+X] =>> List[X] ` . This allows type constructors
5555to be compared with type lambdas.
5656
5757## Relationship with Parameterized Type Definitions
@@ -62,7 +62,7 @@ type T[X] = R
6262```
6363is regarded as a shorthand for an unparameterized definition with a type lambda as right-hand side:
6464``` scala
65- type T = [X ] => R
65+ type T = [X ] =>> R
6666```
6767
6868A parameterized abstract type
@@ -71,19 +71,19 @@ type T[X] >: L <: U
7171```
7272is regarded as shorthand for an unparameterized abstract type with type lambdas as bounds.
7373``` scala
74- type T >: ([X ] => L ) <: ([X ] => U )
74+ type T >: ([X ] =>> L ) <: ([X ] => > U )
7575```
7676However, if ` L ` is ` Nothing ` it is not parameterized, since ` Nothing ` is treated as a bottom type for all kinds. For instance,
7777``` scala
7878type T [- X ] <: X => ()
7979```
8080is expanded to
8181``` scala
82- type T >: Nothing <: ([- X ] => X => ())
82+ type T >: Nothing <: ([- X ] =>> X => ())
8383```
8484instead of
8585``` scala
86- type T >: ([X ] => Nothing ) <: ([- X ] => X => ())
86+ type T >: ([X ] =>> Nothing ) <: ([- X ] => > X => ())
8787```
8888
8989The same expansions apply to type parameters. E.g.
@@ -92,7 +92,7 @@ The same expansions apply to type parameters. E.g.
9292```
9393is treated as a shorthand for
9494``` scala
95- [F >: Nothing <: [X ] => Coll [X ]]
95+ [F >: Nothing <: [X ] =>> Coll [X ]]
9696```
9797
9898** Note** : The decision to treat ` Nothing ` as universal bottom type is provisional, and might be changed afer further discussion.
@@ -103,7 +103,7 @@ is treated as a shorthand for
103103
104104The body of a type lambda can again be a type lambda. Example:
105105``` scala
106- type TL = [X ] => [Y ] => (X , Y )
106+ type TL = [X ] =>> [Y ] => > (X , Y )
107107```
108108Currently, no special provision is made to infer type arguments to such curried type lambdas. This is left for future work.
109109
0 commit comments