无形镜片的想法

mak*_*aks 4 scala intellij-idea shapeless

我尝试使用版本2.0.0的shapless镜头scala 2.10.3我有类似于这个的代码:

import shapeless._
case class A(map: Map[String, String])
case class B(a: A)
val mapLens = lens[B] >> 'a >> 'map 
Run Code Online (Sandbox Code Playgroud)

理念中的感染类型mapLens

AnyRef with Lens[B, Nothing] {val gen: LabelledGeneric.Aux[Nothing, ::[record.FieldType[Witness.Lt[Symbol]#T, Nothing], Nothing]]}
Run Code Online (Sandbox Code Playgroud)

所以如果我想改变B实例的值

mapLens.set(b)(b.a.map + ("foo" -> "bar"))
Run Code Online (Sandbox Code Playgroud)

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

PS 这里有一个使用无定形镜片的例子.这lens[Person].address.street是怎么回事?我的意思是编译器如何允许我们在lense类的实例上调用case类的方法?因为在LenseExamples对象中使用了>>运算符

编辑 已在REPL中尝试过并且有效.Idea说它

could not find implicit value for evidence parameter of type shapeless.LabelledGeneric[B]{type Repr = Out0}
Run Code Online (Sandbox Code Playgroud)

同样的抱怨发出了争吵

Mil*_*bin 5

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