Unable to map on HList

旧街凉风 提交于 2019-11-27 08:58:29

There's an easy fix: just define your function as an object instead of a val:

object f extends (({ type O2[+A] = (Option[A], Option[A]) })#O2 ~> Option) {
  def apply[A](x: (Option[A], Option[A])): Option[A] = x._1 orElse x._2
}

(Note that I've named the function f instead of mapper to avoid confusion with the mapper implicit argument to map.)

I'm not sure I can help with why—at some point I tried to work out the details of why val wouldn't work for this kind of thing in Shapeless, and I don't remember how far I got.

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