Add biased operators to Ior#1500
Merged
Merged
Conversation
Current coverage is 92.12% (diff: 100%)@@ master #1500 diff @@
==========================================
Files 246 246
Lines 3689 3693 +4
Methods 3569 3568 -1
Messages 0 0
Branches 120 125 +5
==========================================
+ Hits 3397 3402 +5
+ Misses 292 291 -1
Partials 0 0
|
2672a09 to
a486d23
Compare
johnynek
reviewed
Dec 21, 2016
| final def merge[AA >: A](implicit ev: B <:< AA, AA: Semigroup[AA]): AA = | ||
| fold(identity, ev.apply, (a, b) => AA.combine(a, b)) | ||
| final def mergeLeft[AA >: A](implicit ev: B <:< AA): AA = | ||
| fold(identity, ev.apply, (a, _) => a) |
Contributor
There was a problem hiding this comment.
I don't think you need ev.apply here. I think B <:< AA is already a function B => AA so you can pass it directly without allocating another closure.
Although, it would be interesting to know if scalac avoids allocating a closure when you do fn.apply and instead just passes fn.
Contributor
Author
There was a problem hiding this comment.
Good point, fixed it in merge too.
a486d23 to
f48a142
Compare
Contributor
|
👍 |
Contributor
|
👍, looks reasonable to me. |
johnynek
requested changes
Jan 2, 2017
| case Ior.Both(a, b) => fab(a, b) | ||
| } | ||
|
|
||
| final def putLeft[AA >: A](left: AA): AA Ior B = |
Contributor
There was a problem hiding this comment.
actually, why does this need to be AA >: A and not just AA? Aren't we fully replacing? Same with putRight?
Add put operators, make ev.apply explicit Add putLeft and putRight tests Use ev directly instead of eta-expanding More polymorphism, thanks johnynek
f48a142 to
6735c43
Compare
Contributor
Author
|
Thanks @johnynek, fixed. |
johnynek
approved these changes
Jan 3, 2017
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ior is sometimes used in a very biased way. These tools make for convenient use in that case.