Skip to content

Commit 14b20c8

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

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

library/src/scala/Tuple.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,12 @@ 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 {
89+
case EmptyTuple => EmptyTuple
8890
case _ *: EmptyTuple => EmptyTuple
8991
case x *: xs =>
90-
xs match {
91-
case _ *: EmptyTuple =>
92-
x *: EmptyTuple
93-
case _ =>
94-
x *: Init[xs]
95-
}
92+
x *: Init[xs]
9693
}
9794

9895
/** Type of the tail of a tuple */
@@ -101,13 +98,15 @@ object Tuple {
10198
}
10299

103100
/** Type of the last of a tuple */
104-
type Last[X <: NonEmptyTuple] = Reduce[X, EmptyTuple] match {
101+
@experimental
102+
type Last[X <: Tuple] = Reduce[X, EmptyTuple] match {
105103
case x *: xs => xs match {
106104
case EmptyTuple => x
107105
}
108106
}
109107

110108
/** Type of the reduce of the first tuple to a tuple of arity 1 or provide the second tuple as a result */
109+
@experimental
111110
type Reduce[X <: Tuple, Y <: Tuple] <: Tuple = X match {
112111
case EmptyTuple => Y
113112
case x *: xs => xs match {

0 commit comments

Comments
 (0)