0
je suite à un projet qui contient le code suivant:erreur Shapeless: not found: Deuxième valeur
package ch.khinkali
import shapeless.{::, HList, HNil}
trait Second[L <: HList] {
type Out
def apply(value: L): Out
}
object Second {
type Aux[L <: HList, O] = Second[L] {type Out = O}
def apply[L <: HList](implicit inst: Second[L]): Aux[L, inst.Out] =
inst
}
object Main {
implicit def hlistSecond[A, B, Rest <: HList]: Second.Aux[A :: B :: Rest, B] =
new Second[A :: B :: Rest] {
type Out = B
def apply(value: A :: B :: Rest): B =
value.tail.head
}
def main(args: Array[String]): Unit = {
val second1 = Second[String :: Boolean :: Int :: HNil]
println(second1)
}
}
Lorsque je tente sur la Shell
suivante:
val second1 = Second[String :: Boolean :: Int :: HNil]
il affiche le message d'erreur:
J'importe le paquet, comme vous pouvez le voir l'image ci-dessous:error: not found: value Second
Qu'est-ce que je fais mal?
J'ai autre erreur 'erreur: nombre incorrect d'arguments de type pour ::, devrait être 1' –
@zero_coding Mise à jour. –
Et encore une erreur encore 'erreur: impossible de trouver la valeur implicite pour le paramètre inst: ch.khinkali.Second [String :: Boolean :: Int :: shapeless.HNil]', \t bien que j'ai une instance pour cela, comme vous pouvez voir le code ci-dessus. –