Essentially, I want something like this:
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)
It fails to compile with:
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)
obviously has the type FoldFn
, but the compiler won't accept the LeftFolder
instance.
How can I get this to work?