-
-
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
Partially revert 4530d3aa93131ec28096968a3c903ed1016dbf1b. Add back v… #1506
Partially revert 4530d3aa93131ec28096968a3c903ed1016dbf1b. Add back v… #1506
Conversation
… Either syntax.
Current coverage is 92.32% (diff: 100%)@@ master #1506 diff @@
==========================================
Files 246 246
Lines 3659 3659
Methods 3534 3540 +6
Messages 0 0
Branches 125 119 -6
==========================================
+ Hits 3369 3378 +9
+ Misses 290 281 -9
Partials 0 0
|
👍 from me. We'll need to fix the docs (for example) to match, and I'd prefer to see that happen in this PR, I guess, but it could be a follow-up. |
} | ||
} | ||
|
||
def partialCompare(that: Either[A, B])(implicit A: PartialOrder[A], B: PartialOrder[B]): Double = eab match { | ||
def partialCompare[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: PartialOrder[AA], BB: PartialOrder[BB]): Double = eab match { |
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.
this method is untested. Is it too much to ask to write a test of some kind during this PR?
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.
Not at all. Will do
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.
Actually this one should be covered by order laws at https://github.com/typelevel/cats/blob/master/tests/src/test/scala/cats/tests/EitherTests.scala#L44 , right?
EDIT: Ah, it isn't because implementation of partialCompare
in EitherInstances
is duplicated in EitherOps
. Is it better to dedup these two?
def show(implicit A: Show[A], B: Show[B]): String = eab match { | ||
case Left(a) => s"Left(${A.show(a)})" | ||
case Right(b) => s"Right(${B.show(b)})" | ||
def show[AA >: A, BB >: B](implicit AA: Show[AA], BB: Show[BB]): String = eab match { |
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.
this is untested. Can we add a simple test?
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.
Of course
} | ||
|
||
def ap[C](that: Either[A, B => C]): Either[A, C] = (new EitherOps(that)).flatMap(this.map) | ||
def ap[AA >: A, BB >: B, C](that: Either[AA, BB => C]): Either[AA, C] = new EitherOps(that).flatMap(this.map) |
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.
this is untested. Can we add a simple test?
I'll take care of docs update as well, Thanks for pointing out. |
My codecov plugin seems to say that codecov thinks it is uncovered.
…On Thu, Dec 29, 2016 at 16:39 Marcin Rzeźnicki ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/src/main/scala/cats/syntax/either.scala
<#1506>:
> }
}
- def partialCompare(that: Either[A, B])(implicit A: PartialOrder[A], B: PartialOrder[B]): Double = eab match {
+ def partialCompare[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: PartialOrder[AA], BB: PartialOrder[BB]): Double = eab match {
Actually this one should be covered by order laws at
https://github.com/typelevel/cats/blob/master/tests/src/test/scala/cats/tests/EitherTests.scala#L44
, right?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1506>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdtPkInW2SvIicSWzHBYtoqqMjzcDks5rNG7GgaJpZM4LXi16>
.
|
Maybe we aren't exercising this call site. The laws can't be calling this
one since PartialOrder is invariant.
On Thu, Dec 29, 2016 at 18:49 P. Oscar Boykin <[email protected]>
wrote:
… My codecov plugin seems to say that codecov thinks it is uncovered.
On Thu, Dec 29, 2016 at 16:39 Marcin Rzeźnicki ***@***.***>
wrote:
***@***.**** commented on this pull request.
------------------------------
In core/src/main/scala/cats/syntax/either.scala
<#1506>:
> }
}
- def partialCompare(that: Either[A, B])(implicit A: PartialOrder[A], B: PartialOrder[B]): Double = eab match {
+ def partialCompare[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: PartialOrder[AA], BB: PartialOrder[BB]): Double = eab match {
Actually this one should be covered by order laws at
https://github.com/typelevel/cats/blob/master/tests/src/test/scala/cats/tests/EitherTests.scala#L44
, right?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1506>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEJdtPkInW2SvIicSWzHBYtoqqMjzcDks5rNG7GgaJpZM4LXi16>
.
|
Missing tests added in 5c86c44 |
@travisbrown It looks like the whole 'Either in the small...' chapter can be removed from the docs since |
@marcin-rzeznicki Yep, that makes sense to me. |
…`flatMap` now behaves identically to 2.12
@@ -212,132 +212,6 @@ magic("123") match { | |||
} | |||
``` | |||
|
|||
## Either in the small, Either in the large | |||
Once you start using `Either` for all your error-handling, you may quickly run into an issue where |
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.
Why is this being removed?
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.
@adelbertc The idea is that all the stuff about the left sides needing to be the same will be a lot less relevant (or not at all relevant, in the form here) once the syntax flatMap
for Either
behaves the same as the real flatMap
method on Either
in 2.12.
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.
This section talks about using local ADTs for local errors and wrapping as you go wider and wider in your application. Variance is tangentially relevant to Solution 1 but does not help with Solution 2.
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.
Okay, you've convinced me the removal should be more surgical. :)
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.
Nonetheless, the whole section was presented as a 'solution' - but the problem being solved does not exist anymore. To quote the relevant part: 'If you're on Scala 2.12, this line will compile and work as expected (...)'. Everything that followed seemed to have been written as a guide to deal with issues on previous versions of Scala. It of course does not invalidate ideas contained therein. Obviously, organizing your errors as ADTs is a valid and useful technique. But a rather generic one and not really tied to usage of Either
in cats. Of course I'm open to any suggestions, but I must admit that I simply do not know what should be there instead.
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 should strive to present certain patterns (for lack of a better word) for using these data types - in this case I wrote it to show how one could use Either
throughout their code to represent possibly failing computations.
@@ -212,132 +212,6 @@ magic("123") match { | |||
} | |||
``` | |||
|
|||
## Either in the small, Either in the large |
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.
Please be more careful about removing this section - variance does not subsume the concerns here.
Deleted section is still relevant - it was meant to present use of `Either` to reprsent failing computations. Variance or not, it is more aout how to use this data type. I tried to rewrote parts that are no longer true in presence of variance. Some other parts have been rearranged.
@adelbertc I've come up with a new version of docs. Only some parts that had been no longer true in presence of variance were rewritten. Some other parts were rearranged. Please check if you like it. ( Since Contributors' Guide discourages squashing commits, it may be awkward to compare :-( ) |
Cool @marcin-rzeznicki , LGTM, thanks! |
…ariance on methods in EitherT and Either syntax.
Current signatures make it impossible to write, for example, for-comprehensions with 'lefts' not being of the same type. The following code does not compile with current signatures, but it compiles after the change (compiler is able to infer the common supertype):
This change has been discussed on gitter with @travisbrown and @edmundnoble