-
-
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 count as syntax to UnorderedFoldable #2520
Add count as syntax to UnorderedFoldable #2520
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2520 +/- ##
==========================================
+ Coverage 95.35% 95.36% +<.01%
==========================================
Files 358 359 +1
Lines 6530 6532 +2
Branches 282 280 -2
==========================================
+ Hits 6227 6229 +2
Misses 303 303
Continue to review full report at Codecov.
|
Hi @leusgalvan thanks a lot for contributing! Is there a reason you're using the underscore syntax, why not just |
@LukaJCB only because when I tried to use it in a simple way, the
|
* res2: Long = 1 | ||
* }}} | ||
*/ | ||
def count_(p: A => Boolean)(implicit F: UnorderedFoldable[F]): Long = |
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.
Maybe it'd be better to have count
defined in the UnorderedFoldable
trait itself, and only call count
here? Otherwise you can only use it with the syntax implicits, and not just F.count
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.
You can't do that if you want to maintain binary compat.
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.
Aww damn :( the encoding of traits strikes again
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.
we should be able to define extensions for typeclass instances, like:
implicit class UFOps[F[_]](val instance: UnorderedFoldable[F]) extends AnyVal {
def count(...)
}
@leusgalvan I think I'd prefer to just call it See |
@LukaJCB if it's called Although it may be alright to keep it that way here, because there's a perfectly sane |
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.
Looks great, one small thing is that I think we should add this to the cats.syntax
package object :)
Fixes #2447 .