-
-
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
Add contravariant instances for Const and Kleisli #626
Conversation
Ah thanks, I was running into diverging implicits with |
@@ -93,6 +93,12 @@ class KleisliTests extends CatsSuite { | |||
checkAll("SemigroupK[Lambda[A => Kleisli[Option, A, A]]]", SerializableTests.serializable(kleisliSemigroupK)) | |||
} | |||
|
|||
{ | |||
implicit val kleisliContravariant = Kleisli.kleisliContravariant[Option, Int] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I correct to guess that you were forced into doing this because the implicit instances wasn't inferred?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I've just checked and it works fine without. I was just blindly following the pattern in the rest of the test suite. Happy to push up without if that's preferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if it can be inferred then we should probably let it be inferred in the tests. If nothing else, it provides an extra test that we don't break implicit resolution for this instance without realizing it :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through and changed KleisliTests to not explicitly specify the implicits.
Current coverage is
|
@philwills Sorry for the hassle, but I think that while it was fine to not be explicit about the If you just type In some places we are using a In the case of the |
The issues with the tests are subtle, and hopefully at some point we form a good convention for this sort of thing. But other than that, the actual implementation looks correct and clean to me. Thanks for this, @philwills! |
ac58e2f
to
697c4ad
Compare
OK, I've reverted the change to all but the new test. Thanks for being so clear with your explanation. |
Looks great! 👍 |
Looks good to me. Thanks @philwills ! 👍 |
Add contravariant instances for Const and Kleisli
I realise that this is very similar to @vikraman's work in #590, but I think this addresses the issues raised by @ceedubs and it was much easier to get this working against master than raising a PR onto that branch, thanks to the removal of
ArbitraryK
.