|
| 1 | +import scala.compiletime.ops.int |
| 2 | + |
| 3 | +type Count0[N,T] <: Tuple = (N,T) match |
| 4 | + case (0,_) => EmptyTuple |
| 5 | + case (N,String) => String *: Count0[int.-[N, 1], String] |
| 6 | + case (N,Int) => Int *: Count0[int.-[N, 1], Int] |
| 7 | + case (N,Float) => Float *: Count0[int.-[N, 1], Float] |
| 8 | + case (N,Double) => Double *: Count0[int.-[N, 1], Double] |
| 9 | + |
| 10 | + |
| 11 | +type Count1[N,T] <: Tuple = (N,T) match |
| 12 | + case (0,T) => EmptyTuple |
| 13 | + case (N,String) => String *: Count1[int.-[N, 1], String] |
| 14 | + case (N,Int) => Int *: Count1[int.-[N, 1], Int] |
| 15 | + case (N,Float) => Float *: Count1[int.-[N, 1], Float] |
| 16 | + case (N,Double) => Double *: Count1[int.-[N, 1], Double] |
| 17 | + |
| 18 | +def t01 = summon[Count0[1, Int] =:= Int *: EmptyTuple ] |
| 19 | +def t02 = summon[Count0[2, Int] =:= Int *: Int *: EmptyTuple] |
| 20 | +def t03 = summon[Count0[3, Int] =:= Int *: Int *: Int *: EmptyTuple] |
| 21 | +def t04 = summon[Count0[4, Int] =:= Int *: Int *: Int *: Int *: EmptyTuple] |
| 22 | +def t05 = summon[Count0[5, Int] =:= Int *: Int *: Int *: Int *: Int *: EmptyTuple] |
| 23 | + |
| 24 | +def t11 = summon[Count1[1, Int] =:= Int *: EmptyTuple ] |
| 25 | +def t12 = summon[Count1[2, Int] =:= Int *: Int *: EmptyTuple] |
| 26 | +def t13 = summon[Count1[3, Int] =:= Int *: Int *: Int *: EmptyTuple] // was: Fail from here |
| 27 | +def t14 = summon[Count1[4, Int] =:= Int *: Int *: Int *: Int *: EmptyTuple] |
| 28 | +def t15 = summon[Count1[5, Int] =:= Int *: Int *: Int *: Int *: Int *: EmptyTuple] |
0 commit comments