【发布时间】:2014-01-03 01:27:23
【问题描述】:
所以我想在HList 上创建一个映射函数,但我需要检查应用函数内部的一些条件。喜欢:
object test extends Poly1 {
implicit def default[L <: HList](implicit head: ops.hlist.IsHCons[L]) =
at[L](t => {
if(true) t.head else false //here some condition
})
}
因此,我们丢失了 t.head 元素中有关 type 的所有信息;顺便说一句,如果我们构建“干净”功能:
object test extends Poly1 {
implicit def default[L <: HList](implicit head: ops.hlist.IsHCons[L]) =
at[L](t => t.head)
}
那么,显然,一切都好。
所以问题是:如何处理它,并制作这样的功能(如果可能的话)或者我应该寻找另一种方式?为什么这里可以进行类型擦除?
【问题讨论】:
标签: scala types map shapeless hlist