问题
I am using Shapeless 2.2.5. I try to convert a tuple to HList using the code below.
import shapeless._
import syntax.std.product._
(23, "foo", 2.0, true).productElements
But I get a compilation error.
[error] /scala/testScala/src/test/scala/lombok/shapeless/TestTuple2HList.scala:12: could not find implicit value for parameter gen: shapeless.Generic[(Int, String, Double, Boolean)]
[error] (23, "foo", 2.0, true).productElements
The test conversions.scala in https://github.com/milessabin/shapeless/blob/master/core/src/test/scala/shapeless/conversions.scala
did not provide an implicit value for Generic[(Int,String,Double,Boolean)].
Have I missed some imports ?
Thanks in advance for any assistance !
Shing
回答1:
It should be import syntax.std.tuple._
rather than import syntax.std.product._
.
来源:https://stackoverflow.com/questions/35258391/tuple-to-hlist-using-productelements