24得票2回答
无形库 - 将一个具有不同字段顺序的case类转换为另一个

我正在考虑做类似于安全地将不同类型的样例类字段复制到另一个样例类,但是需要重新排序字段,即:case class A(foo: Int, bar: Int) case class B(bar: Int, foo: Int) 我希望有一种方法可以将 A(3, 4) 转换为 B(4, 3) - s...

19得票1回答
从LabelledGeneric实例中提取标签值

考虑以下示例:import shapeless._ case class Foo(bar: String, baz: Boolean) val labl = LabelledGeneric[Foo] 现在,labl的类型是(美化后)LabelledGeneric[Foo] { type ...

9得票1回答
将类型参数传递以用作参数LabelledGeneric

我试图对一个需要处理泛型类型 A 的方法进行参数化,在这个类型上可以检索到 LabelledGeneric。以下是一种朴素的方法: case class Foo(bar: String, baz: Boolean) def params[A](a: A) = { val lbl = L...

8得票1回答
使用shapeless标签与LabelledGenerics

假设我想像这里描述的那样遍历案例类的通用表示方式。 我已经定义了一些类型类来描述字段: trait Described[X] extends (X => String) object Described{ def apply[X](x: X)(implicit desc: Des...

7得票4回答
错误:无法将<haven_labelled>转换为字符。

我和我的学生都加载了相同的数据集,安装了相同的软件包,并运行了相同的代码。当我运行 "frq" 时,我得到了一个频率表,并且该变量被标记为 "numeric"。但是当我的学生运行相同的代码时,她会收到错误信息 "Error: Can't convert &lt;haven_labelled&g...