-
-
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
Missing Contravariant instance for OptionT #2548
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2548 +/- ##
==========================================
+ Coverage 95.17% 95.19% +0.01%
==========================================
Files 359 359
Lines 6553 6570 +17
Branches 278 289 +11
==========================================
+ Hits 6237 6254 +17
Misses 316 316
Continue to review full report at Codecov.
|
I believe the problem with scala 2.13 on the CI was related to this scala/bug#11068 |
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.
thanks so much!
Sorry it was a bit noisy. 👍 |
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.
Thanks @barambani! I've left one comment that I think would be an improved check that we have all of the proper instances.
|
||
checkAll("OptionT[Show, ?]", InvariantTests[OptionT[Show, ?]].invariant[Int, Int, Int]) | ||
checkAll("Invariant[OptionT[Show, ?]]", SerializableTests.serializable(Invariant[OptionT[Show, ?]])) | ||
} |
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.
Ideally we'd have a check here for a type that has an Invariant
instance but not a Contravariant
instance to make sure that we cover this use-case. I think that Semigroup
would be an example of such a type.
|
||
private[discipline] sealed trait ArbitraryInstances1 { | ||
|
||
implicit def catsLawsArbitraryForSemigroupOfOption[A](implicit ev: Semigroup[A]): Arbitrary[Semigroup[Option[A]]] = |
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 know that I mentioned Semigroup
as an example of an Invariant
before, but now that I see this I realize that it's awkward (and inefficient) to test. I think that it would simplify things if you use ListWrapper
like we are using it elsewhere to grab an instance with only an Invariant
instance. Sorry for leading you in the wrong direction on this one.
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 will make the change. Not at all, thanks for helping me.
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.
👍 thanks a bunch @barambani!
thank you, 👍 |
It should close #2545
While checking the Invariant I noticed that there is an issue with the priority of ContravariantMonoidal and Traverse in Const so I fixed it and added tests. Can be reproduced with