使用 productElements 元组到 HList
Tuple to HList using productElements
我正在使用 Shapeless 2.2.5。
我尝试使用下面的代码将元组转换为 HList。
import shapeless._
import syntax.std.product._
(23, "foo", 2.0, true).productElements
但是我得到一个编译错误。
[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
测试conversions.scala中
https://github.com/milessabin/shapeless/blob/master/core/src/test/scala/shapeless/conversions.scala
没有为 Generic[(Int,String,Double,Boolean)] 提供隐式值。
我是不是漏掉了一些导入?
在此先感谢您的帮助!
盛
应该是import syntax.std.tuple._
而不是import syntax.std.product._
。
我正在使用 Shapeless 2.2.5。 我尝试使用下面的代码将元组转换为 HList。
import shapeless._
import syntax.std.product._
(23, "foo", 2.0, true).productElements
但是我得到一个编译错误。
[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
测试conversions.scala中 https://github.com/milessabin/shapeless/blob/master/core/src/test/scala/shapeless/conversions.scala
没有为 Generic[(Int,String,Double,Boolean)] 提供隐式值。
我是不是漏掉了一些导入?
在此先感谢您的帮助!
盛
应该是import syntax.std.tuple._
而不是import syntax.std.product._
。