在下面的例子中,我得到找不到参数zipper的隐含值:shapeless.ops.hlist.Zip [shapeless。:: [keys.Out,shapeless。:: [mapper.Out,shapeless。高抗扰度逻辑]]]
我认为我需要另一个隐含的,但无法解决语法问题。想法?
def mapCCLV[P <: Product, K <: HList, L <: HList, M <: HList](p: P)(poly: Poly1)(
implicit gen: Generic.Aux[P, L], lab: LabelledGeneric.Aux[P, K],
keys: Keys[K], mapper: Mapper.Aux[poly.type, L, M]) = {
val k = keys.apply
val v = gen.to(p).map(poly)
k.zip(v)
}
答案 0 :(得分:4)
与错误消息一样,您需要为var today = DateTime.Now;
var activeMembers = allMembers.Where(m =>
m.Memberships.Any(ms =>
ms.Status == "Active" &&
(ms.StartDate == null || ms.StartDate <= today) && (ms.EndDate == null || today <= ms.EndDate)));
类型类实例提供额外的隐式参数,以便能够压缩。
Zip
您更有可能想要使用import shapeless._, shapeless.ops.hlist._, record._, ops.record._, labelled._
def mapCCLV[P <: Product, LG <: HList, K <: HList, G <: HList, M <: HList](
p: P)(poly: Poly1
)(implicit
gen: Generic.Aux[P, G],
lab: LabelledGeneric.Aux[P, LG],
keys: Keys.Aux[LG, K],
mapper: Mapper.Aux[poly.type, G, M],
zip: Zip[K :: M :: HNil]
): zip.Out = {
val k = keys()
val v = gen.to(p).map(poly)
k.zip(v)
}
代替ZipWithKeys
。
Zip