我尝试将2.0.0版的无矫正镜片用于scala 2.10.3
我有与此类似的代码:

import shapeless._
case class A(map: Map[String, String])
case class B(a: A)
val mapLens = lens[B] >> 'a >> 'map
mapLens的推断类型是
AnyRef with Lens[B, Nothing] {val gen: LabelledGeneric.Aux[Nothing, ::[record.FieldType[Witness.Lt[Symbol]#T, Nothing], Nothing]]}

所以如果我想改变B实例的值
mapLens.set(b)(b.a.map + ("foo" -> "bar"))

我收到类型不匹配错误。如何解决这个问题?

P.S. Here有使用无形镜片的示例。这个lens[Person].address.street如何运作?我的意思是编译器如何允许我们在lense类的实例上调用case类的方法?因为在LenseExamples对象中使用>>运算符

编辑
已经在REPL中尝试过,并且可以正常工作。想法说
could not find implicit value for evidence parameter of type shapeless.LabelledGeneric[B]{type Repr = Out0}

相同的提示发出gra声

最佳答案

想法是错误的。您应该针对Scala插件报告一个错误。

10-01 21:45