Skip to content

Commit 1c3f350

Browse files
committed
Expand spec page
1 parent acee9bd commit 1c3f350

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

docs/docs/reference/type-lambdas-spec.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,42 @@ where `v1` and `v2` are optional variance annotations: `+`, `-`, or absent.
4242
Then `TL1 <: TL2`, if the type interval `L2..U2` is contained in the type interval `L1..U1` (i.e.
4343
`L1 <: L2` and `U2 <: U1`), and either `v2` is absent or `v1 = v2`.
4444

45+
## Relationship with Parameterized Type Definitions
46+
47+
A parameterized type definition
48+
```
49+
type T[X] = R
50+
```
51+
is regarded as a shorthand for an unparameterized definition with a type lambda as right-hand side:
52+
```
53+
type T = [X] => R
54+
```
55+
56+
A parameterized abstract type
57+
```
58+
type T[X] >: L <: U
59+
```
60+
is regarded as shorthand for an unparameterized abstract type with type lambdas as bounds.
61+
```
62+
type T >: ([X] => L) <: ([X] => U)
63+
```
64+
However, if `L` is `Nothing` it is not parameterized, since `Nothing` is treated as a bottom type for all kinds. For instance,
65+
```
66+
type T[-X] <: X => ()
67+
```
68+
is expanded to
69+
```
70+
type T >: Nothing <: ([-X] => X => ())
71+
```
72+
instead of
73+
```
74+
type T >: ([X] => Nothing) <: ([-X] => X => ())
75+
```
76+
77+
**Note**: The decision to treat `Nothing` as universal bottom type is provisional, and might be changed afer further discussion.
78+
79+
**Note**: Scala 2 and 3 differ in that Scala 2 also treats `Any` as universal top-type. This is not done in Scala 3. See also the discussion on [kind polymorphism](./kind-polymorphism.html)
80+
4581

4682

4783

docs/docs/reference/type-lambdas.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ right-hand side:
2121

2222
type T = [X] => (X, X)
2323

24-
[More details](./type-lambdas-spec.md)
24+
[More details](./type-lambdas-spec.html)

0 commit comments

Comments
 (0)