I'm trying to define some structure like this
case class Transformer[From, To](
name: String,
get: PaymentEvent => From,
to: From => To
I want to filter elements with names that are part of a Set
class filterName(names: Set[String]) extends lowPriority {
implicit def get[From, To] = at[Transformer[From, To]]{ trans =>
if (names.contains(trans.name))
trans :: HNil
else
HNil
}
}
This is the concrete value:
type HTransformer = Transformer[String, String] :: Transformer[Long, Long] :: HNil
When I want to apply the function to the value
private def filter(fields: HTransformer, names: Set[String]): HTransformer = {
fields.flatMap(new filterName(names))
}
The compiler reports errors:
Error:(42, 19) could not find implicit value for parameter mapper: shapeless.ops.hlist.FlatMapper[f.type,shapeless.::[com.ingenico.datalake.Transformer[String,String],shapeless.::[com.ingenico.datalake.Transformer[Long,Long],shapeless.HNil]]]
fields.flatMap(new filterName(names))
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…