Skip to content

Commit 38c2309

Browse files
committed
Use X <: Tuple bound for Tuple.{Init|Last}
1 parent 809d7b7 commit 38c2309

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

library/src/scala/Tuple.scala

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,11 @@ object Tuple {
8484
}
8585

8686
/** Type of the initial part of the tuple without its last element */
87-
type Init[X <: NonEmptyTuple] <: Tuple = X match {
87+
@experimental
88+
type Init[X <: Tuple] <: Tuple = X match {
8889
case _ *: EmptyTuple => EmptyTuple
8990
case x *: xs =>
90-
xs match {
91-
case _ *: EmptyTuple =>
92-
x *: EmptyTuple
93-
case _ =>
94-
x *: Init[xs]
95-
}
91+
x *: Init[xs]
9692
}
9793

9894
/** Type of the tail of a tuple */
@@ -101,13 +97,15 @@ object Tuple {
10197
}
10298

10399
/** Type of the last of a tuple */
104-
type Last[X <: NonEmptyTuple] = Reduce[X, EmptyTuple] match {
100+
@experimental
101+
type Last[X <: Tuple] = Reduce[X, EmptyTuple] match {
105102
case x *: xs => xs match {
106103
case EmptyTuple => x
107104
}
108105
}
109106

110107
/** Type of the reduce of the first tuple to a tuple of arity 1 or provide the second tuple as a result */
108+
@experimental
111109
type Reduce[X <: Tuple, Y <: Tuple] <: Tuple = X match {
112110
case EmptyTuple => Y
113111
case x *: xs => xs match {

0 commit comments

Comments
 (0)