@@ -118,6 +118,7 @@ object Tuple:
118
118
// even though it only matches non-empty tuples.
119
119
// Avoids bounds check failures from an irreducible type
120
120
// like `Tuple.Head[Tuple.Tail[X]]`
121
+ // Other types that don't reduce for empty tuples follow the same principle.
121
122
type Head [X <: Tuple ] = X match
122
123
case x *: _ => x
123
124
@@ -273,22 +274,6 @@ object Tuple:
273
274
*/
274
275
type Union [T <: Tuple ] = Fold [T , Nothing , [x, y] =>> x | y]
275
276
276
- /** A type level Boolean indicating whether the tuple `X` conforms
277
- * to the tuple `Y`. This means:
278
- * - the two tuples have the same number of elements
279
- * - for corresponding elements `x` in `X` and `y` in `Y`, `x` matches `y`.
280
- * @pre The elements of `X` are assumed to be singleton types
281
- */
282
- type Conforms [X <: Tuple , Y <: Tuple ] <: Boolean = Y match
283
- case EmptyTuple =>
284
- X match
285
- case EmptyTuple => true
286
- case _ => false
287
- case y *: ys =>
288
- X match
289
- case `y` *: xs => Conforms [xs, ys]
290
- case _ => false
291
-
292
277
/** A type level Boolean indicating whether the tuple `X` has an element
293
278
* that matches `Y`.
294
279
* @pre The elements of `X` are assumed to be singleton types
@@ -350,25 +335,14 @@ object Tuple:
350
335
351
336
extension [X <: Tuple ](inline x : X )
352
337
353
- /** The index (starting at 0) of the first element in the type `X` of `x`
354
- * that matches type `Y` .
338
+ /** The index (starting at 0) of the first occurrence of y.type in the type `X` of `x`
339
+ * or Size[X] if no such element exists .
355
340
*/
356
- inline def indexOfType [ Y ] = constValue[IndexOf [X , Y ]]
341
+ transparent inline def indexOf ( y : Any ) : Int = constValue[IndexOf [X , y. type ]]
357
342
358
- /** A boolean indicating whether there is an element in the type `X` of `x`
359
- * that matches type `Y`.
343
+ /** A boolean indicating whether there is an element `y.type` in the type `X` of `x`
360
344
*/
361
- inline def containsType [Y ] = constValue[Contains [X , Y ]]
362
-
363
- /* Note: It would be nice to add the following two extension methods:
364
-
365
- inline def indexOf[Y: Precise](y: Y) = constValue[IndexOf[X, Y]]
366
- inline def containsType[Y: Precise](y: Y) = constValue[Contains[X, Y]]
367
-
368
- because we could then move indexOf/contains completely to the value level.
369
- But this requires `Y` to be inferred precisely, and therefore a mechanism
370
- like the `Precise` context bound used above, which does not yet exist.
371
- */
345
+ transparent inline def contains (y : Any ): Boolean = constValue[Contains [X , y.type ]]
372
346
373
347
end extension
374
348
@@ -380,7 +354,7 @@ object Tuple:
380
354
using eqHead : CanEqual [H1 , H2 ], eqTail : CanEqual [T1 , T2 ]
381
355
): CanEqual [H1 *: T1 , H2 *: T2 ] = CanEqual .derived
382
356
383
- object helpers :
357
+ private object helpers :
384
358
385
359
/** Used to implement IndicesWhere */
386
360
type IndicesWhereHelper [X <: Tuple , P [_] <: Boolean , N <: Int ] <: Tuple = X match
0 commit comments