HList上的映射引发了AbstractMethodError

时间:2016-09-07 15:31:47

标签: scala runtime-error read-eval-print-loop shapeless

我在REPL中尝试shapeless示例并收到运行时错误:

scala> import shapeless._
import shapeless._

scala> import shapeless.poly._
import shapeless.poly._

scala> object choose extends (Set ~> Option) {
     |   def apply[T](set: Set[T]) = set.headOption
     | }
defined object choose

scala> val sets = Set(1) :: Set(0) :: HNil
sets: shapeless.::[scala.collection.immutable.Set[Int],shapeless.::[scala.collection.immutable.Set[Int],shapeless.HNil]] = Set(1) :: Set(0) :: HNil

scala> sets map choose
java.lang.AbstractMethodError: choose$.caseUniv()Lshapeless/PolyDefns$Case;
  ... 42 elided

你知道为什么它不起作用以及如何解决它?

0 个答案:

没有答案