I'm trying to use shapeless to do additions and removals from Hlist
s. But I can't seem to get it to work.
So I here are my lists:
object ShapelessExample {
import shapeless._
def main(args: Array[String]): Unit = {
case class Container[T <: Singleton](name: T)
val a = Container("A") :: Container("B") :: Container("C") :: HNil
val b = Container("B") :: Container("C") :: HNil
println {
a.removeAll[b.type] //doesn't work
}
}
}
So the removeAll
method on Hlist
only takes a type parameter, but I can't seem to use b.type
. I can manually specify a.removeAll[Container["B"] :: Container["C"] :: HNil]
, but is there any way to just use b
's type?
Shapeless tries to remove precisely type
b.type
but can't find it amongContainer["A"] :: Container["B"] :: Container["C"] :: HNil
so @user is correct, singleton typeb.type
is too specific.In order to infer an
HList
type from aval
singleton type try to modify the methodor