-
-
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
Enable breakout in functions nonEmptyTraverse_ and nonEmptySequence_ #3545
Conversation
0492bbd
to
72aaf16
Compare
72aaf16
to
1470081
Compare
Codecov Report
@@ Coverage Diff @@
## master #3545 +/- ##
==========================================
- Coverage 91.32% 91.30% -0.03%
==========================================
Files 386 386
Lines 8592 8565 -27
Branches 269 248 -21
==========================================
- Hits 7847 7820 -27
Misses 745 745 |
@@ -182,7 +182,7 @@ import scala.annotation.implicitNotFound | |||
* the traversal. | |||
*/ | |||
def nonEmptyTraverse_[G[_], A, B](fa: F[A])(f: A => G[B])(implicit G: Apply[G]): G[Unit] = | |||
G.void(reduceLeftTo(fa)(f)((x, y) => G.map2(x, f(y))((_, b) => b))) | |||
G.void(reduceRightTo(fa)(f)((x, y) => G.map2Eval(f(x), y)((_, b) => b)).value) |
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.
should we not void after each f
? couldn't that be a win rather than voiding at the end?
f1 = f.andThen(G.void(_))
or:
val f1 = f.andThen(G.void(_))
G.void(reduceRightTo(fa)(f1)((x, y) => G.map2Eval(G.void(f(x)), y)((_, b) => b)).value)
4b78114
to
170c4b5
Compare
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.
Thanks!
ref: #3015 #3498