I'm trying to split a list of size S at N, where it is known that N, M sum up to S. This does not compile:
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]
}
Errors
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.
Final correct version
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]
}
The type
A
needs to be the type of the elements of the list, not the size argument again. That's why it's trying to convert to a GenTraversableLike[A, List[Int]]
. You need to set A
to Int
in each case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With