¿Cómo escribir correctamente anotar esta lista H?
sealed abstract trait HList
case class :+:[H, T <: HList](head: H, tail: T) extends HList {
def :+:[T](v: T) = new :+:(v, this)
}
case object HNil extends HList {
def :+:[T](v: T) = new :+:(v, this)
}
object HListExpt {
def main(args: Array[String]) {
val me: String :+: Int :+: Symbol :+: HNil.type = "Rahul" :+: 20 :+: 'Male :+: HNil
println(me.head, me.tail.head)
}
}
Al intentar compilar el código anterior, aparece el siguiente error del compilador:
error: type mismatch;
found : :+:[java.lang.String,:+:[Int,:+:[Symbol,object HNil]]]
required: :+:[String,:+:[Int,:+:[Symbol,HNil.type]]]
val me: String :+: Int :+: Symbol :+: HNil.type = "Rahul" :+: 20 :+: 'Male :+: HNil
¿Qué estoy haciendo mal aquí? ¿Cuál sería la forma correcta de escribir-anotar lo anterior?HList
?
PD: el código se compila bien cuando elimino la anotación de tipo.