简体   繁体   中英

Shapeless lenses in idea

I try to use shapless lenses of version 2.0.0 for scala 2.10.3 I have the code similar to this one:

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

the infered type in idea of mapLens is

AnyRef with Lens[B, Nothing] {val gen: LabelledGeneric.Aux[Nothing, ::[record.FieldType[Witness.Lt[Symbol]#T, Nothing], Nothing]]}

so if I want to change value of B instance

mapLens.set(b)(b.a.map + ("foo" -> "bar"))

I get a type mismatch error. How to fix this?

PS Here there is an example of using shapeless lenses. How does this lens[Person].address.street works? I mean how does compiler allow us to call methods of case class on instance of lense class? Because in LenseExamples object the >> operator is used

edit Have tried in REPL and it works. Idea says that it

could not find implicit value for evidence parameter of type shapeless.LabelledGeneric[B]{type Repr = Out0}

The same complain emits gradle

Idea is wrong. You should report a bug against the Scala plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM