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

Variance for optics type parameters #1049

Open
kenbot opened this issue Feb 11, 2021 · 1 comment
Open

Variance for optics type parameters #1049

kenbot opened this issue Feb 11, 2021 · 1 comment
Labels
3.x Next major version

Comments

@kenbot
Copy link
Collaborator

kenbot commented Feb 11, 2021

Add variance to the optics type parameters, eg [-S, +T, +A, -B].

Julien:

It helps with Some(1).focus(_.some).replace(2)

Without variance, I believe you get an error and need to manually upcast Some(1): Option[Int]

This example used to work in Monocly: https://github.com/optics-dev/Monocly/blob/master/src/main/scala/Main.scala#L24-L26

@kenbot kenbot added the 3.x Next major version label Feb 11, 2021
@julien-truffaut
Copy link
Member

It is likely we will have some issues with cats typeclasses beeing invariants like Functor or Applicative. We need to use @uncheckedVariance annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.x Next major version
Projects
None yet
Development

No branches or pull requests

2 participants