Skip to content

Enable breakout in functions nonEmptyTraverse_ and nonEmptySequence_#3545

Merged
LukaJCB merged 2 commits into
typelevel:masterfrom
takayahilton:fix-nonemptytraverse_
Aug 4, 2020
Merged

Enable breakout in functions nonEmptyTraverse_ and nonEmptySequence_#3545
LukaJCB merged 2 commits into
typelevel:masterfrom
takayahilton:fix-nonemptytraverse_

Conversation

@takayahilton
Copy link
Copy Markdown
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
@takayahilton takayahilton force-pushed the fix-nonemptytraverse_ branch from 72aaf16 to 1470081 Compare August 3, 2020 14:01
LukaJCB
LukaJCB previously approved these changes Aug 3, 2020
@codecov-commenter
Copy link
Copy Markdown

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              

*/
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
Copy Markdown
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)

@takayahilton takayahilton force-pushed the fix-nonemptytraverse_ branch from 4b78114 to 170c4b5 Compare August 4, 2020 05:24
@takayahilton takayahilton requested a review from johnynek August 4, 2020 06:38
Copy link
Copy Markdown
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