无形的错误:未找到:值第二

时间:2017-10-16 08:34:20

标签: scala shapeless

我有一个包含以下代码的项目:

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)
  }

}

当我尝试以下Shell时:

 val second1 = Second[String :: Boolean :: Int :: HNil]

它显示错误消息:

 error: not found: value Second

我确实导入了包,如下图所示:

enter image description here

我做错了什么?

1 个答案:

答案 0 :(得分:2)

尝试使用通配符:

import ch.khinkali._
import shapeless._
import ch.khinkali.Main._