-
-
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 instance for Eq and test Show instance. #1211
Add Contravariant instance for Eq and test Show instance. #1211
Conversation
Perhaps we could do a heuristic test by generating a bunch of |
Current coverage is 89.18%@@ master #1211 diff @@
==========================================
Files 234 234
Lines 3144 3152 +8
Methods 3085 3094 +9
Messages 0 0
Branches 57 56 -1
==========================================
+ Hits 2804 2811 +7
- Misses 340 341 +1
Partials 0 0
|
👍 great! |
* Create an approximation of Eq[Eq[A]] by generating 100 values for A | ||
* and comparing the application of the two eqv functions | ||
*/ | ||
implicit def catsLawsEqForEq[A](implicit arbA: Arbitrary[(A, A)], booleanEq: Eq[Boolean]): Eq[Eq[A]] = new Eq[Eq[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 don't really think we need the Eq[Boolean]
here. I think we assume that primitives are okay to compare directly.
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.
That makes sense, I adapted catsLawsEqForOrder
where an Eq[Int]
is used.
👍 |
👍 |
As far I can tell this seemed to be the only missing
Contravariant
instance.#579 also mentioned
StateT
, but I think only anIndexedStateT
would have aContravariant
(that's also why there is noProfunctor
instance, see #1067).I don't think it is possible to test the instance for
Eq
, sinceCovariantTests
would need anArbitrary[Eq[A]]
and anEq[Eq[A]]
?