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 #2310

Closed
julien-truffaut opened this Issue Jul 3, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@julien-truffaut
Copy link
Collaborator

julien-truffaut commented Jul 3, 2018

Do you know why Validated is covariant on its two type (like Either) but EitherT is invariant?

sealed abstract class Validated[+E, +A]
final case class EitherT[F[_], A, B]
@johnynek

This comment has been minimized.

Copy link
Collaborator

johnynek commented Jul 3, 2018

Wouldn’t it require F[+_]? Which limits us. Note Functor has widen and Bifunctor has leftWiden which you can use like explicit covariance.

@julien-truffaut

This comment has been minimized.

Copy link
Collaborator

julien-truffaut commented Jul 3, 2018

@johnynek you're probably right, make sense. I guess it is just annoying that we have to treat Either and EitherT differently in a for comprehension. It doesn't help that intellij doesn't recognize leftWiden (but that's another issue).

@henricook

This comment has been minimized.

Copy link

henricook commented Jul 13, 2018

Has anyone got any clue why IntelliJ doesn't recognise leftWiden?

ceedubs added a commit to ceedubs/typelevel.github.com that referenced this issue Sep 30, 2018

Add a blog post aboutn variance and monad transformers
Every once in a while [people](typelevel/cats#556) [ask](typelevel/cats#2310) [about](typelevel/cats#2538) this.

I thought that it would be nice to provide a more detailed answer in a
single place so we can link to it from the Cats FAQ.

Note: I had to add the `-Ypartial-unification` flag for one of the code
samples to compile. It's quite possible that I should be doing this a
different way than I did.

ceedubs added a commit to ceedubs/typelevel.github.com that referenced this issue Sep 30, 2018

Add a blog post about variance and monad transformers
Every once in a while [people](typelevel/cats#556) [ask](typelevel/cats#2310) [about](typelevel/cats#2538) this.

I thought that it would be nice to provide a more detailed answer in a
single place so we can link to it from the Cats FAQ.

Note: I had to add the `-Ypartial-unification` flag for one of the code
samples to compile. It's quite possible that I should be doing this a
different way than I did.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment