Skip to content

Commit 398bc5b

Browse files
committed
Address comments
1 parent 6436b4b commit 398bc5b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

docs/docs/reference/auto-parameter-tupling-spec.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ xs.map {
1818
case (x, y) => x + y
1919
}
2020
```
21-
While correct, this is also inconvenient. Instead, automatic tupling of function parameters proposed to be able to write it the following way:
21+
While correct, this is inconvenient. Instead, we propose to be able to write it the following way:
2222

2323
```scala
2424
xs.map {
@@ -30,21 +30,20 @@ or, equivalently:
3030
xs.map(_ + _)
3131
```
3232

33-
Generally, a function value with `n > 1` parameters can be converted to a pattern-matching closure using case if the expected type is a unary function type of the form `((T_1, ..., T_n)) => U`.
33+
Generally, a function value with `n > 1` parameters can be converted to a function with tupled arguments if the expected type is a unary function type of the form `((T_1, ..., T_n)) => U`.
3434

3535
### Type Checking
3636

37-
Let a function `F` of the form `F = (p1, ..., pn) => E` for `n != 1`, parameters `p1, ..., pn`, and an expression `E`.
37+
Let a function `f` of the form `(p1, ..., pn) => e` for `n != 1`, parameters `p1, ..., pn`, and an expression `e`.
3838

39-
40-
If the expected type of `F` is a fully defined function type or SAM-type that has a
39+
If the expected type of `f` is a fully defined function type or SAM-type that has a
4140
single parameter of a subtype of `ProductN[T1, ..., Tn]`, where each type `Ti` fits the corresponding
4241
parameter `pi`.
4342

44-
A type `T` fits a parameter `p` if one of the following two cases is `true`:
43+
A type `Ti` fits a parameter `pi` if one of the following two cases is `true`:
4544

46-
* `p` comes without a type, i.e. it is a simple identifier or `_`.
47-
* `p` is of the form `x: U` or `_: U` and `T` conforms to `U`.
45+
* `pi` comes without a type, i.e. it is a simple identifier or `_`.
46+
* `pi` is of the form `x: Ui` or `_: Ui` and `Ti` conforms to `Ui`.
4847

4948
Auto-tupling composes with eta-expansion. That is an n-ary function generated by eta-expansion
5049
can in turn be adapted to the expected type with auto-tupling.
@@ -53,7 +52,7 @@ can in turn be adapted to the expected type with auto-tupling.
5352

5453
If the a function
5554
```scala
56-
(p1: T1, ..., pn: Tn) => E
55+
(p1: T1, ..., pn: Tn) => e
5756
```
5857

5958
is typed as `ProductN[T1, ..., Tn] => Te`, then it will be transformed to
@@ -63,7 +62,7 @@ is typed as `ProductN[T1, ..., Tn] => Te`, then it will be transformed to
6362
def p1: T1 = x._1
6463
...
6564
def pn: Tn = x._n
66-
E
65+
e
6766
}
6867
```
6968

@@ -74,9 +73,9 @@ Translation of such a tuples would use the `apply` method on the tuple to access
7473

7574
### Migration
7675

77-
Code like this could not be written before, hence the new notation would not be ambigouous after addoptation.
76+
Code like this could not be written before, hence the new notation would not be ambigouous after adoption.
7877

79-
Thought it is possible that someone has written an implicit conversion for `(T1, ..., Tn) => R` into `TupleN[T1, ..., Tn]`
78+
Though it is possible that someone has written an implicit conversion form `(T1, ..., Tn) => R` to `TupleN[T1, ..., Tn] => R`
8079
for some `n`. This change could be detected and fixed by `Scalafix`. Furthermore, such conversion would probably
8180
be doing the same translation (semantically) but in a less efficient way.
8281

0 commit comments

Comments
 (0)