-
-
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 max/min and reduceOption methods #1167
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,12 @@ import simulacrum.typeclass | |
val F = self | ||
val G = Reducible[G] | ||
} | ||
|
||
def minimum[A](fa: F[A])(implicit A: Order[A]): A = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did this specifically to avoid collision with the std lib. If I refactor something from a Having said that, there's a question of how much we should bend over backwards to avoid collisions with std lib names. I'm not set in stone on this if people would prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case you would have Is that what you mean? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johnynek yes that's what I mean, but note that we already have syntax enrichment for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @johnynek do you have any further thoughts on this after my note about the syntax enrichment that currently exists? If there's a strong preference for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see... I'm not a huge implicit syntax fan (this example, but also confusion for novices as to where methods are coming from). But I recognize many cats users do like this, so avoiding the collision seems safest. 👍 |
||
reduceLeft(fa)(A.min) | ||
|
||
def maximum[A](fa: F[A])(implicit A: Order[A]): A = | ||
reduceLeft(fa)(A.max) | ||
} | ||
|
||
/** | ||
|
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.
what about
minOption
. Do we need such a long name?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.
This is just to be consistent with
minimum
. Is this okay considering the discussion here?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.
totally. Sorry. I'm +1 on the whole PR. My 👍 above may not have been clear about that.