2017-10-16 2 views
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 

enter image description here

Qu'est-ce que je fais mal?

Répondre

2

importations génériques Try:

import ch.khinkali._ 
import shapeless._ 
import ch.khinkali.Main._ 
+0

J'ai autre erreur 'erreur: nombre incorrect d'arguments de type pour ::, devrait être 1' –

+0

@zero_coding Mise à jour. –

+0

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. –