File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ // https://github.com/lampepfl/dotty/issues/10242
2+ type Foo [A , B <: A ] = A
3+
4+ type Bar [A ] = A match {
5+ case Foo [String , x] => Unit
6+ }
7+
8+ import scala .compiletime .ops .int .*
9+
10+ sealed trait HList
11+ final case class HCons [H <: Int & Singleton , T <: HList ](head : H , tail : T )
12+ extends HList
13+ sealed trait HNil extends HList
14+ case object HNil extends HNil
15+
16+ sealed trait Tensor [T , S <: HList ]
17+
18+ object tf :
19+ def zeros [S <: HList ](shape : S ): Tensor [Float , S ] = ???
20+
21+ type NumElements [X <: HList ] <: Int = X match
22+ case HNil => 1
23+ case HCons [head, tail] => head * NumElements [tail]
24+
25+ def reshape [T , From <: HList , To <: HList ](
26+ tensor : Tensor [T , From ],
27+ shape : To
28+ )(using NumElements [From ] =:= NumElements [To ]): Tensor [T , To ] = ???
29+
30+ object test :
31+ val x = HCons (1 , HCons (2 , HNil ))
32+ val y = tf.reshape(tf.zeros(x), HCons (2 , HCons (1 , HNil )))
You can’t perform that action at this time.
0 commit comments