Skip to content

Commit 9507c1f

Browse files
committed
Rename TupledFunction.{tuple|untuple} to tupled and untupled
To have the same naming convention as scala.Function.{tupled|untupled}
1 parent 5e209f5 commit 9507c1f

8 files changed

+64
-64
lines changed

docs/docs/reference/other-new-features/tupled-function.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ Now that we have functions and tuples generalized to [arities above 22](https://
1111
The type class `TupleFunction` provides a way to abstract directly over a function of any arity converting it to an equivalent function that receives all arguments in a single tuple.
1212

1313
```scala
14-
/** Type class relating a `FunctionN[..., R]` with an equvalent tupled function `Function1[TupleN[...], R]`
14+
/** Type class relating a `FunctionN[..., R]` with an equivalent tupled function `Function1[TupleN[...], R]`
1515
*
1616
* @tparam F a function type
1717
* @tparam G a tupled function type (function of arity 1 receiving a tuple as argument)
1818
*/
1919
@implicitNotFound("${F} cannot be tupled as ${G}")
2020
sealed trait TupledFunction[F, G] {
21-
def tuple(f: F): G
22-
def untuple(g: G): F
21+
def tupled(f: F): G
22+
def untupled(g: G): F
2323
}
2424
```
2525

@@ -43,7 +43,7 @@ Examples
4343
* @tparam Args the tuple type with the same types as the function arguments of F
4444
* @tparam R the return type of F
4545
*/
46-
def (f: F) tupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): Args => R = tf.tuple(f)
46+
def (f: F) tupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f)
4747
```
4848

4949
`TupledFunction` can be used to generalize the `Function.untupled` methods to functions of any arities ([full example](https://github.com/lampepfl/dotty/tests/run/tupled-function-untupled.scala))
@@ -58,7 +58,7 @@ def (f: F) tupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]):
5858
* @tparam Args the tuple type with the same types as the function arguments of F
5959
* @tparam R the return type of F
6060
*/
61-
def (f: Args => R) untupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): F = tf.untuple(f)
61+
def (f: Args => R) untupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): F = tf.untupled(f)
6262
```
6363

6464
`TupledFunction` can also be used to generalize the [`Tuple1.compose`](https://github.com/lampepfl/dotty/tests/run/tupled-function-compose.scala) and [`Tuple1.andThen`](https://github.com/lampepfl/dotty/tests/run/tupled-function-andThen.scala) methods to compose functions of larger arities and with functions that return tuples.
@@ -73,6 +73,6 @@ def (f: Args => R) untupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Ar
7373
* @tparam R the return type of F
7474
*/
7575
def (f: F) compose[F, G, FArgs <: Tuple, GArgs <: Tuple, R](g: G) given (tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = {
76-
(x: GArgs) => tf.tuple(f)(tg.tuple(g)(x))
76+
(x: GArgs) => tf.tupled(f)(tg.tupled(g)(x))
7777
}
7878
```

library/src-3.x/scala/TupledFunction.scala

Lines changed: 51 additions & 51 deletions
Large diffs are not rendered by default.

tests/run/tupled-function-andThen.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Test {
3333
* @tparam R the return type of G
3434
*/
3535
def (f: F) andThen[F, G, FArgs <: Tuple, GArgs <: Tuple, R](g: G) given (tf: TupledFunction[F, FArgs => GArgs], tg: TupledFunction[G, GArgs => R]): FArgs => R = {
36-
x => tg.tuple(g)(tf.tuple(f)(x))
36+
x => tg.tupled(g)(tf.tupled(f)(x))
3737
}
3838

3939
}

tests/run/tupled-function-apply.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,5 @@ object Test {
114114
* @tparam R the return type of F
115115
*/
116116
def (f: F) apply[F, Args <: Tuple, R](args: Args) given (tf: TupledFunction[F, Args => R]): R =
117-
tf.tuple(f)(args)
117+
tf.tupled(f)(args)
118118
}

tests/run/tupled-function-compose.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object Test {
3434
* @tparam R the return type of F
3535
*/
3636
def (f: F) compose[F, G, FArgs <: Tuple, GArgs <: Tuple, R](g: G) given (tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = {
37-
x => tf.tuple(f)(tg.tuple(g)(x))
37+
x => tf.tupled(f)(tg.tupled(g)(x))
3838
}
3939

4040
}

tests/run/tupled-function-extension-method.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ object Test {
4040

4141
// Applied to all funtions of arity 2 or more (including more than 22 parameters)
4242
def (e: Expr[F]) apply[F, Args <: Tuple, R](args: Args) given (tf: TupledFunction[F, Args => R]): R =
43-
tf.tuple(e.x)(args)
43+
tf.tupled(e.x)(args)
4444
def (e: Expr[F]) applyGiven[F, Args <: Tuple, R](args: Args) given (tf: TupledFunction[F, given Args => R]): R =
45-
tf.tuple(e.x) given args
45+
tf.tupled(e.x) given args
4646

4747
}

tests/run/tupled-function-tupled.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ object Test {
2424
* @tparam Args the tuple type with the same types as the function arguments of F
2525
* @tparam R the return type of F
2626
*/
27-
def (f: F) tupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): Args => R = tf.tuple(f)
27+
def (f: F) tupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f)
2828
}

tests/run/tupled-function-untupled.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ object Test {
104104
* @tparam Args the tuple type with the same types as the function arguments of F
105105
* @tparam R the return type of F
106106
*/
107-
def (f: Args => R) untupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): F = tf.untuple(f)
107+
def (f: Args => R) untupled[F, Args <: Tuple, R] given (tf: TupledFunction[F, Args => R]): F = tf.untupled(f)
108108
}

0 commit comments

Comments
 (0)