Infinite lenses in the idea

I am trying to use formless lenses version 2.0.0 for scala 2.10.3 I have code similar to this:

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

the inferred type in the idea mapLensis equal to

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

so if i want to change the value of instance B

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

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

PS Here is an example of using shapeless lenses. How does this work lens[Person].address.street? I mean, how does the compiler allow us to call case class methods using the Lense class as an example? Since the LenseExamplesoperator uses the → operator

edit Tried in REPL and it works. Idea says she

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

The same complaints emit gradle

+4
1

. Scala.

+5

Source: https://habr.com/ru/post/1542069/


All Articles