基本上,我想要这样的东西:
class FoldFn(l: HList) extends Poly {
// stuff
}
def doStuff[L <: HList](l: L)(implicit folder: LeftFolder.Aux[L, Int, FoldFn, Int]): Int =
l.foldLeft(0)(new FoldFn(l))(folder)
无法编译:
type mismatch
found : shapeless.ops.hlist.LeftFolder.Aux[L,Int,FoldFn,Int]
(which expands to) shapeless.ops.hlist.LeftFolder[L,Int,FoldFn]{type Out = Int}
required: shapeless.ops.hlist.LeftFolder[L,Int,op.type]
new FoldFn(l)
显然属于FoldFn
类型,但编译器不接受LeftFolder
实例。
我怎样才能让它发挥作用?