Is it possible to make the following code work?
def zeroTo[N <: Nat]:Sized[List[Int], N] = {
new Sized[List[Int], N](List.iterate(0, toInt[N])(1+)) {
type A = Int
}
}
I get a compile error saying “could not find implicit value for parameter toIntN: shapeless.ToInt[N]”.
You can just add a context bound:
Which gives us:
Note that you can write this more or less equivalently as the following using
wrap:Update: Version for Shapeless 2.2.0: