Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing is broken for literals #39

Open
kenbot opened this issue May 19, 2017 · 0 comments
Open

Indexing is broken for literals #39

kenbot opened this issue May 19, 2017 · 0 comments
Labels
Milestone

Comments

@kenbot
Copy link
Owner

kenbot commented May 19, 2017

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)
@kenbot kenbot added this to the 1.1 milestone May 19, 2017
@kenbot kenbot added the bug label May 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant