【发布时间】:2019-04-08 04:22:04
【问题描述】:
我想将一些案例类转换为HList,然后用索引压缩返回的HList,然后用索引映射它:
class B[A]() {
def foo[H <: HList](tuple: A)(implicit gen: Generic.Aux[A, H],
zip: ZipWithIndex[H],
mapper: Mapper[UpdateOps.type, ZipWithIndex[H]#Out]) = {
gen.to(tuple).zipWithIndex.map(UpdateOps)
}
}
UpdateOps 是一个包对象:
object UpdateOps extends Poly1 {
??? // not implemented yet
}
问题是我得到了一个编译错误:
错误:(24, 35) 找不到参数映射器的隐式值: shapeless.ops.hlist.Mapper[UpdateOps.type,zip.Out] gen.to(tuple).zipWithIndex.map(UpdateOps) 错误:(24, 35) 方法映射的参数不足:(隐式映射器: shapeless.ops.hlist.Mapper[UpdateOps.type,zip.Out])mapper.Out。 未指定的值参数映射器。 gen.to(tuple).zipWithIndex.map(UpdateOps)
如果我只是映射 HList 则没有错误,但我需要保存索引。 有可能实现吗?
【问题讨论】: