问题
I am trying a shapeless
example in REPL and getting a runtime error:
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
Do you know why it doesn't work and how to fix it ?
来源:https://stackoverflow.com/questions/39374015/mapping-over-hlist-raises-abstractmethoderror