Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

P.S. 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

like image 735
maks Avatar asked May 26 '14 17:05

maks


1 Answers

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

like image 55
Miles Sabin Avatar answered Oct 31 '22 17:10

Miles Sabin