-
-
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 minimumBy/maximumBy/Option to Foldable #3084
Conversation
Let's add these to the type class. Now that we dropped 2.11 on master it's BC to add methods to trait. The syntax addition can be a PR to the Scala_2.11 branch |
* `mimimumByOption` / `maximumByOption` on `Foldable` * `minumumBy` / `maximumBy` on `Reducible`
e4a8daa
to
449d54f
Compare
Looks like unrelated failure:
|
Codecov Report
@@ Coverage Diff @@
## master #3084 +/- ##
==========================================
+ Coverage 93.49% 93.49% +<.01%
==========================================
Files 368 368
Lines 6979 6983 +4
Branches 184 195 +11
==========================================
+ Hits 6525 6529 +4
Misses 454 454
Continue to review full report at Codecov.
|
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.
Lgtm thanks!
@@ -192,6 +192,20 @@ abstract class FoldableSuite[F[_]: Foldable](name: String)(implicit ArbFInt: Arb | |||
} | |||
} | |||
|
|||
test(s"Foldable[$name].maximumBy/minimumBy") { |
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.
sorry I should've mentioned this in the earlier comment. Can we make these laws like the other _Ref
laws in Foldable Laws and Reducible laws?
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.
Hmm I'm not sure what you mean 🤔 couldn't find _Ref
anywhere in the file.
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.
Ah ok I found them. Ok I will add some laws. Should I keep the tests in the suite?
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.
I think having them in law is enough. sorry I should've been clear about where the law code is.
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.
Hmm, if I want to add tests for minimum/maximum to FoldableTests
that would mean adding an Order
constraint on B
in def foldable[A: Arbitrary, B: Arbitrary]
, which is not binary compatible.
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.
Ah, right. Then we can't add to laws. We can only use the current tests
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.
Thanks! Lgtm
mimimumByOption
/maximumByOption
onFoldable
minumumBy
/maximumBy
onReducible
Thank you for contributing to Cats!
Fixes #2385