You are very close, but the definition is a chooselittle wrong: mapaccepts Poly1not a Poly2.
You map the hlist of tuples, so you need a polymorphic function that takes one argument (tuple). Instead, you provide a polymorphic function with two arguments. The difference is subtle, but it is.
, :
import shapeless.{ HNil, Poly1 }
object choose extends Poly1 {
implicit def caseInt =
at[(Int,Int)]{
case (_,n) if n > 0 => n
case (o,_) => o
}
implicit def caseString =
at[(String,String)] {
case (_,n) if n.nonEmpty => n
case(o,_) => o
}
}
val g = "a" :: "" :: 0 :: HNil
val h = "" :: "a" :: 5 :: HNil
g.zip(h).map(choose)
, Poly1 Poly2 at .