When a literal is interpolated in an index position, the type is overspecialised to the exact literal instance type (Int(1), String("abc"), Char('a') etc), rather than the expected type (Int, String. Char).
I believe the problem lies in the code that parses the implicit monocle.function.Index[S,I,A] instance.
Example:
scala> val x = Map("a" -> 1, "b" -> 2, "c" -> 3)
x: scala.collection.immutable.Map[String,Int] = Map(a -> 1, b -> 2, c -> 3)
scala> get"$x[${"a"}]"
<console>:29: error: No implicit monocle.function.Index[scala.collection.immutable.Map[String,Int], String("a"), _] found to support '[]' indexing
scala> get"$x[${"a": String}]"
res27: Option[Int] = Some(1)
When a literal is interpolated in an index position, the type is overspecialised to the exact literal instance type (
Int(1)
,String("abc")
,Char('a')
etc), rather than the expected type (Int
,String
.Char
).I believe the problem lies in the code that parses the implicit
monocle.function.Index[S,I,A]
instance.Example: