HList折叠函数需要HList

时间:2015-01-03 01:30:10

标签: scala shapeless

基本上,我想要这样的东西:

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实例。
我怎样才能让它发挥作用?

0 个答案:

没有答案