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

UnorderedFoldable#isEmpty default implementation is incorrect #2586

Merged
merged 3 commits into from
Oct 30, 2018
Merged

UnorderedFoldable#isEmpty default implementation is incorrect #2586

merged 3 commits into from
Oct 30, 2018

Conversation

barambani
Copy link
Contributor

Fixes issue #2584 and adds some tests.

@codecov-io
Copy link

codecov-io commented Oct 29, 2018

Codecov Report

Merging #2586 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2586      +/-   ##
==========================================
+ Coverage   95.14%   95.16%   +0.01%     
==========================================
  Files         361      361              
  Lines        6634     6634              
  Branches      282      294      +12     
==========================================
+ Hits         6312     6313       +1     
+ Misses        322      321       -1
Impacted Files Coverage Δ
core/src/main/scala/cats/UnorderedFoldable.scala 92.85% <100%> (+7.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a317c46...972db96. Read the comment docs.

kailuowang
kailuowang previously approved these changes Oct 29, 2018
Copy link
Contributor

@kailuowang kailuowang left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for the update of the tests!

@barambani
Copy link
Contributor Author

👍

@@ -18,7 +18,7 @@ import cats.instances.long._
* Returns true if there are no elements. Otherwise false.
*/
def isEmpty[A](fa: F[A]): Boolean =
exists(fa)(Function.const(true))
!exists(fa)(Function.const(true))

Copy link
Member

Choose a reason for hiding this comment

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

Tiny tiny nitpick but nonEmpty now negates exists twice. Maybe we should define nonEmpty as exists(fa)(Function.const(true)) and then isEmpty as !nonEmpty WDYT? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I started from that :), but then I changed it as I had the impression it was reading better in my head (not exists instead of not non empty). But I don't really love my version either, as you said double negates, and even if it's simple logic, that makes reasoning convoluted and unnatural. I'm happy to change it 👍.

Copy link
Member

@LukaJCB LukaJCB left a comment

Choose a reason for hiding this comment

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

Thanks a ton for fixing this so quickly! :)

@barambani
Copy link
Contributor Author

thank you for the great help. As usual 👍

@LukaJCB LukaJCB merged commit f5bd5b0 into typelevel:master Oct 30, 2018
@barambani barambani deleted the issue-2584 branch October 30, 2018 13:56
@kailuowang kailuowang added this to the 1.5 milestone Oct 30, 2018
@kailuowang kailuowang added the bug label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants