Skip to content

Commit 9231155

Browse files
Add an infix shorthand for Append[X, Y]
as is the case for `Concat`
1 parent 1c30071 commit 9231155

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/src/scala/Tuple.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ sealed trait Tuple extends Product:
2222
runtime.Tuples.toIArray(this)
2323

2424
/** Return a copy of `this` tuple with an element appended */
25-
inline def :* [This >: this.type <: Tuple, L](x: L): Append[This, L] =
25+
inline def :* [This >: this.type <: Tuple, L](x: L): This :* L =
2626
runtime.Tuples.append(x, this).asInstanceOf[Append[This, L]]
2727

2828
/** Return a new tuple by prepending the element to `this` tuple.
@@ -34,7 +34,7 @@ sealed trait Tuple extends Product:
3434
/** Return a new tuple by concatenating `this` tuple with `that` tuple.
3535
* This operation is O(this.size + that.size)
3636
*/
37-
inline def ++ [This >: this.type <: Tuple](that: Tuple): Concat[This, that.type] =
37+
inline def ++ [This >: this.type <: Tuple](that: Tuple): This ++ that.type =
3838
runtime.Tuples.concat(this, that).asInstanceOf[Concat[This, that.type]]
3939

4040
/** Return the size (or arity) of the tuple */
@@ -161,6 +161,9 @@ object Tuple:
161161
case EmptyTuple => Y *: EmptyTuple
162162
case x *: xs => x *: Append[xs, Y]
163163

164+
/** An infix shorthand for `Append[X, Y]` */
165+
infix type :*[X <: Tuple, Y] = Append[X, Y]
166+
164167
/** Type of the concatenation of two tuples `X` and `Y` */
165168
type Concat[X <: Tuple, +Y <: Tuple] <: Tuple = X match
166169
case EmptyTuple => Y

0 commit comments

Comments
 (0)