i try to merge to HLists with Ints. The resulte should be a list with the sums of the ints. I have a problem moving the code to a separate object (in this case "Adder"). If i do everything inline it works as expected. But this does not compile and I'm not sure why:
import shapeless._
import shapeless.ops.hlist._
object Test extends App {
val a = 1 :: 2 :: 3 :: HNil
val b = 1 :: 1 :: 1 :: HNil
import Adder._
val res = add(a, b)
println(res)
}
object Adder {
object addp extends Poly2 {
implicit val caseIntInt = at[Int, Int](_ + _)
}
def add[T <: HList](a: T, b: T)(implicit zipWith: ZipWith.Aux[T, T, addp.type, T]): T = {
a.zipWith(b)(addp)
}
}
The implicit resolution does not work:
[error] E:\development\scala-test\src\main\scala\Test.scala:13: could not find implicit value for parameter zipWith: shapeless.ops.hlist.ZipWith.Aux[shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]],shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]],test.Adder.addp.type,shapeless.::[Int,shapeless.::[Int,shapeless.::[Int,shapeless.HNil]]]]