gpt4 book ai didi

shapeless - 使用 productElements 元组到 HList

转载 作者:行者123 更新时间:2023-12-04 08:56:27 25 4
gpt4 key购买 nike

我正在使用 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 - 使用 productElements 元组到 HList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35258391/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com