-
-
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
Add foldl
and foldr
aliases to Foldable
#2020
Add foldl
and foldr
aliases to Foldable
#2020
Conversation
seems you were on a code base prior to 1.0.0-MF. These alias should probably be added to the type class , but they will break bin compat with 1.0RC1 so it would be helpful if there are more justification in the PR. |
51a577d
to
138bb6f
Compare
Sure, I'll update the initial comment with a more detailed explanation. |
as expected, this fails the binary compat check
we can add an exception filter here |
Cool, thanks for having a look, will update this tomorrow 👍 |
Codecov Report
@@ Coverage Diff @@
## master #2020 +/- ##
==========================================
+ Coverage 95.08% 95.08% +<.01%
==========================================
Files 301 301
Lines 4943 4946 +3
Branches 124 125 +1
==========================================
+ Hits 4700 4703 +3
Misses 243 243
Continue to review full report at Codecov.
|
@kailuowang - since the syntax suite doesn't actually run, I guess codecov doesn't pick it up. Is there somewhere I should add a runtime test for this so as not to affect codecov? |
@felixmulder a good way to add test coverage for such aliases is doctest. How about we mention these aliases and provide some doctests in scala docs for |
@kailuowang - added the doctest 👍 |
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.
Awesome! Thanks very much!
NP, thanks for the pointers :) |
This PR adds aliases for Foldable's
foldRight
andfoldLeft
ops so that the callee can be sure that the correct method is being invoked.Because of syntax extensions the end signature looks like:
This can then lead to some confusion when folding over things which already have the
foldRight
operation, namely pretty much all collections.Even though we do:
the fold won't be evaluated lazily, using
Foldable
's definition offoldRight
instead the stdlib's version will be chosen.To avoid this pitfall, this PR introduces these aliases:
foldr <=> foldRight
foldl <=> foldLeft
these methods can be used safely with syntax extensions.