我正在尝试在 N 处拆分大小为 S 的列表,其中已知 N,M 总和为 S。这不会编译:
def splitIt[N <: Nat,
M <: Nat,
S <: Nat](u: Sized[List[Int], N] {type A = N},
v: Sized[List[Int], M] {type A = M},
t: Sized[List[Int], S] {type A = S})(implicit sum: SumAux[N, M, S]): Unit = {
val z = t.splitAt[N]
}
错误
No implicit view available from List[Int] => scala.collection.GenTraversableLike[S,List[Int]].
not enough arguments for method sizedOps: (implicit evidence$2: List[Int] => scala.collection.GenTraversableLike[S,List[Int]])shapeless.SizedOps[S,List[Int],S]. Unspecified value parameter evidence$2.
最终正确版本
def splitIt[N <: Nat,
M <: Nat, S <: Nat](u: Sized[List[Int], N] {type A = Int},
v: Sized[List[Int], M] {type A = Int},
t: Sized[List[Int], S] {type A = Int})(implicit sum: DiffAux[S, N, M], toInt: ToInt[N]): Unit = {
val z = t.splitAt[N]
}