我正在尝试创建自定义uPickleWriter
以shapeless.HList
转换为简单数组而不是复杂的嵌套对象。
但我无法提供足够的具体证据,我可以用我的poly
我有这个代码:
import upickle.Js
import upickle.default._
import shapeless._
import poly._
import shapeless.ops.hlist.{ToTraversable, Mapper}
object writeItem extends Poly1 {
implicit def item[I](implicit w: Writer[I]) = at[I](w.write)(writer.write)
}
implicit def hListWriter[L <: HList, Mappr <: Mapper[writeItem.type, L] ]
(implicit mapper: Mappr,
trav: ToTraversable.Aux[Mappr#Out, List, Js.Value]) = Writer[L] {
l => Js.Arr(l.map(writeItem).toList[Js.Value]:_*)
}
和编译错误:
找不到参数的隐式值
toTraversableAux: shapeless.ops.hlist.ToTraversable.Aux[mapper.Out,List,upickle.Js.Value]
如何定义函数以通过转换HList
为统一?List
map