Skip to content
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

Merged
merged 3 commits into from
Jul 19, 2016

Conversation

peterneyens
Copy link
Collaborator

As far I can tell this seemed to be the only missing Contravariant instance.

#579 also mentioned StateT, but I think only an IndexedStateT would have a Contravariant (that's also why there is no Profunctor instance, see #1067).

I don't think it is possible to test the instance for Eq, since CovariantTests would need an Arbitrary[Eq[A]] and an Eq[Eq[A]] ?

@adelbertc
Copy link
Contributor

Perhaps we could do a heuristic test by generating a bunch of A's and say two Eqs are equal if they return the same result when equal-ing a bunch of random As?

@codecov-io
Copy link

codecov-io commented Jul 17, 2016

Current coverage is 89.18%

Merging #1211 into master will decrease coverage by <.01%

@@             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          

Sunburst

Powered by Codecov. Last updated by 885acf6...e7957d2

@ceedubs
Copy link
Contributor

ceedubs commented Jul 18, 2016

👍 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]] {
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

@johnynek
Copy link
Contributor

👍

@ceedubs
Copy link
Contributor

ceedubs commented Jul 19, 2016

👍

@ceedubs ceedubs merged commit 585959e into typelevel:master Jul 19, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants