我在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
你知道为什么它不起作用以及如何解决它?