Unable to map on HList
Solution 1:
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.