Skip to content
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

Merged
merged 2 commits into from
Aug 4, 2020

Conversation

takayahilton
Copy link
Contributor

ref: #3015 #3498

@takayahilton takayahilton force-pushed the fix-nonemptytraverse_ branch 2 times, most recently from 0492bbd to 72aaf16 Compare August 3, 2020 12:59
LukaJCB
LukaJCB previously approved these changes Aug 3, 2020
@codecov-commenter
Copy link

codecov-commenter commented Aug 3, 2020

Codecov Report

Merging #3545 into master will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@            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)
Copy link
Contributor

@johnynek johnynek Aug 3, 2020

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)

Copy link
Contributor

@johnynek johnynek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@LukaJCB LukaJCB merged commit 66e6e11 into typelevel:master Aug 4, 2020
@takayahilton takayahilton deleted the fix-nonemptytraverse_ branch August 4, 2020 17:58
@travisbrown travisbrown added this to the 2.2.0-RC3 milestone Aug 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants