-
-
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
Adding more contravariant instances #929
Conversation
implicit val orderInstances: cats.functor.Contravariant[Order] = | ||
new cats.functor.Contravariant[Order] { | ||
def contramap[A, B](fa: Order[A])(f: B => A): Order[B] = fa.on(f) | ||
} |
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'm not 100% sure where instances for types from Algebra belong - happy to move them somewhere a bit less ad-hoc
Current coverage is 89.84%
@@ master #929 diff @@
=======================================
Files 226 180 -46
Lines 2916 2177 -739
Methods 2865 0 -2865
Branches 48 42 -6
=======================================
- Hits 2592 1956 -636
+ Misses 324 221 -103
Partials 0 0
|
I was able (I think) to write an implementation for StateT as: def contramap[B](f: B => A)(implicit F: Contravariant[F], M: Monad[F]) =
StateT(s1 =>
F.contramap(run(s1)) {
case (s2, a) => (s2, f(a))
}
) However, this would typically mean resolving implicits for e.g |
2924820
to
ab31ab1
Compare
Hi @DavidGregory084, sorry for the long wait! These instances look great! Would you be willing to update this PR? As far as instances for the kernel (e.g. contravariant functors for |
ab31ab1
to
04b78ac
Compare
No problem, this should be up to date now 😸 |
Sorry - we've been merging some sweeping PRs recently that have caused a lot of merge conflicts :(. Would you mind updating again? |
04b78ac
to
39fbd28
Compare
@ceedubs Yeah, that's fine, should be up to date again :) |
👍 thanks a bunch, @DavidGregory084! @non would you be willing to do a review before this goes stale again? |
Looks great, thanks! 👍 |
Some more work on #579.