@@ -89,108 +89,6 @@ sealed trait Tuple extends Product {
89
89
90
90
object Tuple {
91
91
92
- // TODO should it be `extension [H](x: H) def *:(tail: Tuple): H *: tuple.type` ?
93
- extension [H , Tail <: Tuple ](x : H )
94
- /** Return a new tuple by prepending the element to `tail` tuple.
95
- * This operation is O(tail.size)
96
- */
97
- def *: (tail : Tail ): H *: Tail = runtime.Tuples .cons(x, tail).asInstanceOf [H *: Tail ]
98
-
99
- extension [This <: Tuple ](tuple : This )
100
- /** Get the head of this tuple */
101
- def head : Head [This ] & Head [tuple.type ] =
102
- runtime.Tuples .apply(tuple, 0 ).asInstanceOf [Head [This ] & Head [tuple.type ]]
103
-
104
- /** Get the tail of this tuple.
105
- * This operation is O(tuple.size)
106
- */
107
- def tail : Tail [This ] & Tail [tuple.type ] =
108
- runtime.Tuples .tail(tuple).asInstanceOf [Tail [This ] & Tail [tuple.type ]]
109
-
110
- /** Return the size (or arity) of the tuple */
111
- def size : Size [This ] & Size [tuple.type ] =
112
- runtime.Tuples .size(tuple).asInstanceOf [Size [This ] & Size [tuple.type ]]
113
-
114
- /** Get the i-th element of this tuple.
115
- * Equivalent to productElement but with a precise return type.
116
- */
117
- def apply (n : Int ): Elem [This , n.type ] & Elem [tuple.type , n.type ] =
118
- runtime.Tuples .apply(tuple, n).asInstanceOf [Elem [This , n.type ] & Elem [tuple.type , n.type ]]
119
-
120
- /** Get the initial part of the tuple without its last element */
121
- def init : Init [This ] & Init [tuple.type ] =
122
- runtime.Tuples .init(tuple).asInstanceOf [Init [This ] & Init [tuple.type ]]
123
-
124
- /** Get the last of this tuple */
125
- def last : Last [This ] & Last [tuple.type ] =
126
- runtime.Tuples .last(tuple).asInstanceOf [Last [This ] & Last [tuple.type ]]
127
-
128
- /** Return a copy of `tuple` with an element appended */
129
- def :* [X ] (x : X ): Append [This , X ] & Append [tuple.type , X ] =
130
- runtime.Tuples .append(x, tuple).asInstanceOf [Append [This , X ] & Append [tuple.type , X ]]
131
-
132
- /** Return a new tuple by concatenating `this` tuple with `that` tuple.
133
- * This operation is O(this.size + that.size)
134
- */
135
- def ++ (that : Tuple ): Concat [This , that.type ] & Concat [tuple.type , that.type ] =
136
- runtime.Tuples .concat(tuple, that).asInstanceOf [Concat [This , that.type ] & Concat [tuple.type , that.type ]]
137
-
138
- /** Given a tuple `(a1, ..., am)`, returns the reversed tuple `(am, ..., a1)`
139
- * consisting all its elements.
140
- */
141
- @ experimental
142
- def reverse : Reverse [This ] & Reverse [tuple.type ] =
143
- runtime.Tuples .reverse(tuple).asInstanceOf [Reverse [This ] & Reverse [tuple.type ]]
144
-
145
- /** Given two tuples, `(a1, ..., an)` and `(a1, ..., an)`, returns a tuple
146
- * `((a1, b1), ..., (an, bn))`. If the two tuples have different sizes,
147
- * the extra elements of the larger tuple will be disregarded.
148
- * The result is typed as `((A1, B1), ..., (An, Bn))` if at least one of the
149
- * tuple types has a `EmptyTuple` tail. Otherwise the result type is
150
- * `(A1, B1) *: ... *: (Ai, Bi) *: Tuple`
151
- */
152
- // TODO change signature? def zip[That <: Tuple](that: That): Zip[This, tuple.type] & Zip[tuple.type, tuple.type] =
153
- def zip [That <: Tuple ](that : That ): Zip [This , That ] & Zip [tuple.type , That ] =
154
- runtime.Tuples .zip(tuple, that).asInstanceOf [Zip [This , That ] & Zip [tuple.type , That ]]
155
-
156
- /** Called on a tuple `(a1, ..., an)`, returns a new tuple `(f(a1), ..., f(an))`.
157
- * The result is typed as `(F[A1], ..., F[An])` if the tuple type is fully known.
158
- * If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
159
- * to be the cons type.
160
- */
161
- def map [F [_]](f : [t] => t => F [t]): Map [This , F ] & Map [tuple.type , F ] =
162
- runtime.Tuples .map(tuple, f).asInstanceOf [Map [This , F ] & Map [tuple.type , F ]]
163
-
164
- /** Given a tuple `(a1, ..., am)`, returns the tuple `(a1, ..., an)` consisting
165
- * of its first n elements.
166
- */
167
- def take (n : Int ): Take [This , n.type ] & Take [tuple.type , n.type ] =
168
- runtime.Tuples .take(tuple, n).asInstanceOf [Take [This , n.type ] & Take [tuple.type , n.type ]]
169
-
170
- /** Given a tuple `(a1, ..., am)`, returns the tuple `(an+1, ..., am)` consisting
171
- * all its elements except the first n ones.
172
- */
173
- def drop (n : Int ): Drop [This , n.type ] & Take [tuple.type , n.type ] =
174
- runtime.Tuples .drop(tuple, n).asInstanceOf [Drop [This , n.type ] & Take [tuple.type , n.type ]]
175
-
176
- /** Given a tuple `(a1, ..., am)`, returns a pair of the tuple `(a1, ..., an)`
177
- * consisting of the first n elements, and the tuple `(an+1, ..., am)` consisting
178
- * of the remaining elements.
179
- */
180
- def splitAt (n : Int ): Split [This , n.type ] & Split [tuple.type , n.type ] =
181
- runtime.Tuples .splitAt(tuple, n).asInstanceOf [Split [This , n.type ] & Split [tuple.type , n.type ]]
182
-
183
- /** Create a copy of this tuple as a List */
184
- def toList : List [Union [This ]] & List [Union [tuple.type ]] =
185
- tuple.productIterator.toList.asInstanceOf [List [Union [This ]] & List [Union [tuple.type ]]]
186
-
187
- extension (tuple : Tuple )
188
- /** Create a copy of this tuple as an Array */
189
- def toArray : Array [AnyRef ] = runtime.Tuples .toArray(tuple)
190
-
191
- /** Create a copy of this tuple as an IArray */
192
- def toIArray : IArray [AnyRef ] = runtime.Tuples .toIArray(tuple)
193
-
194
92
/** Type of a tuple with an element appended */
195
93
type Append [X <: Tuple , Y ] <: NonEmptyTuple = X match {
196
94
case EmptyTuple => Y *: EmptyTuple
@@ -200,7 +98,6 @@ object Tuple {
200
98
/** Type of the head of a tuple */
201
99
type Head [X <: Tuple ] = X match {
202
100
case x *: _ => x
203
- case EmptyTuple => Nothing
204
101
}
205
102
206
103
/** Type of the initial part of the tuple without its last element */
@@ -213,7 +110,6 @@ object Tuple {
213
110
/** Type of the tail of a tuple */
214
111
type Tail [X <: Tuple ] <: Tuple = X match {
215
112
case _ *: xs => xs
216
- case EmptyTuple => Nothing
217
113
}
218
114
219
115
/** Type of the last element of a tuple */
0 commit comments