-
-
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
Fix many cats-kernel instances. #1324
Conversation
This commit does a bunch of things: 1. Move relevant either/function instnaces into kernel 2. Add missing Eq/PartialOrder instances for Either 3. Add many missing instances for Function0/Function1 4. Add instances for BitSet 5. Remove code duplication between collection monoids 6. Improve test coverage of function instances 7. Add some missing package objects in kernel 8. A few stylistic changes This is a relatively large commit but I think almost all of this is stuff we'd like to get done before we freeze cats-kernel.
(Another change I failed to mention was that I made several of the |
Review by @johnynek, plus anyone else who is interested. |
We may want to start using things |
Current coverage is 91.55% (diff: 97.80%)@@ master #1324 diff @@
==========================================
Files 234 237 +3
Lines 3543 3563 +20
Methods 3484 3504 +20
Messages 0 0
Branches 59 59
==========================================
+ Hits 3241 3262 +21
+ Misses 302 301 -1
Partials 0 0
|
👍 looks great to me. I wish we had that |
b => y.fold(_ => 1, B.partialCompare(b, _)) | ||
implicit def catsStdShowForEither[A, B](implicit A: Show[A], B: Show[B]): Show[Either[A, B]] = | ||
new Show[Either[A, B]] { | ||
def show(f: Either[A, B]): String = f.fold( |
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.
we have biased to match
for alleged performance reasons. What do you think of it here?
@@ -61,7 +61,7 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances { | |||
|
|||
def traverse[F[_], B, C](fa: Either[A, B])(f: B => F[C])(implicit F: Applicative[F]): F[Either[A, C]] = | |||
fa match { | |||
case left @ Left(_) => F.pure(left) | |||
case Left(a) => F.pure(Left(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.
maybe: https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/syntax/either.scala#L301
case left @ Left(_) => F.pure(left.rightCast[C])
save an allocation?
This is for you, @johnynek.
@@ -48,7 +48,7 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances { | |||
@tailrec | |||
def tailRecM[B, C](b: B)(f: B => Either[A, Either[B, C]]): Either[A, C] = | |||
f(b) match { | |||
case Left(a) => Left(a) | |||
case left @ Left(_) => left.rightCast[C] | |||
case Right(Left(b1)) => tailRecM(b1)(f) | |||
case Right(Right(c)) => Right(c) |
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.
case Right(r) => r.leftCast[A]
should work, right?
one last allocation to save, then I'm +1 |
@johnynek I think this is it right? |
👍 Thank you for this work! |
This commit does a bunch of things:
This is a relatively large commit but I think almost all of this is
stuff we'd like to get done before we freeze cats-kernel."
This fixes #1320.