Mapping over HList raises AbstractMethodError

旧时模样 提交于 2019-12-11 04:38:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!