问题
To me this appears as a very basic functionality, but I can't find it in current shapeless (2.3.3).
So I am looking for a type Induction[X,F[_],N <: Nat]
with
Induction[X,F,Nat._0].Out =:= X
Induction[X,F,Nat._1].Out =:= F[X]
Induction[X,F,Nat._2].Out =:= F[F[X]]
...
Maybe it's also possible to chain a function along the type construction, e.g., to construct a Point
instance?
回答1:
No there isn't. As you observe this most likely needs a Point
-like type class to be useful. I suggest adding something like this to Kittens which depends on both shapeless and Cats.
来源:https://stackoverflow.com/questions/42410653/is-there-infrastructure-in-shapeless-that-takes-a-type-constructor-to-the-power