2
我正在嘗試爲shapeless.HList
創建自定義uPickle Writer
,以轉換爲簡單數組而不是複雜嵌套對象。用於HList的uPickle Writer
,但我無法提供足夠的具體證據可能我映射我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]:_*)
}
和編譯錯誤:
could not find implicit value for parameter
toTraversableAux: shapeless.ops.hlist.ToTraversable.Aux[mapper.Out,List,upickle.Js.Value]
一個人怎麼能定義函數將HList
轉換爲統一List
通過map
?