-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
should Kleisli contravariant on A? #2749
Comments
Hi @jcouyang I wonder if you could help me with some pointers on the issue you raised. Although I understand the explanation above, and experienced it when composing Kleisli, I am looking for the formal definition of things. What is the machanism that enable to compiler to infer I wonder if i can find those rules somewhere in the specification so that thing does not sound magic to me and is predictable. |
hi @Maatary I think it is the other way around, A1 is upper bound of
by constrain |
Kleisli[F[_], A, B] is supposed to be abstraction of
A => F[B]
, but=>
has type of Function1[-A, +B], I can't figure out why Kleisli is invariant on both A and B, is there any benefit that it's design like this?from what I observed, it will be much easier to let scala compiler find out what A should be
for instance, if I would like to choose from two Kleisli
contravariant on -A
compiler can infer the correct type of the input of Kleisli should be
A2 with A1
and the output will beA1
to achieve the same thing without
-A
will be much difficultby contramap
the compiler can't infer A12 for contramap unless I explicitly tell the compiler that I need
Kleisli[Some, A12, A1]
The text was updated successfully, but these errors were encountered: