Skip to content

Commit

Permalink
backported #3122 Fix constraints and names for new Foldable methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gagandeepkalra authored and travisbrown committed Feb 19, 2020
1 parent d278b04 commit bf5f51f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions core/src/main/scala/cats/syntax/foldable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,12 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
* @return `None` if the structure is empty, otherwise the minimum element
* wrapped in a `Some`.
*
* @see [[Reducible#minimum]] for a version that doesn't need to return an
* @see [[ReducibleOps0.minimumBy]] for a version that doesn't need to return an
* `Option` for structures that are guaranteed to be non-empty.
*
* @see [[maximumOptionBy]] for maximum instead of minimum.
* @see [[FoldableOps0.minimumByOption]] for maximum instead of minimum.
*/
def minimumOptionBy[B: Order](f: A => B)(implicit F: Foldable[F]): Option[A] =
def minimumByOption[B: Order](f: A => B)(implicit F: Foldable[F]): Option[A] =
F.minimumOption(fa)(Order.by(f))

/**
Expand All @@ -324,12 +324,12 @@ final class FoldableOps0[F[_], A](private val fa: F[A]) extends AnyVal {
* @return `None` if the structure is empty, otherwise the maximum element
* wrapped in a `Some`.
*
* @see [[Reducible#maximum]] for a version that doesn't need to return an
* @see [[ReducibleOps0.maximumBy]] for a version that doesn't need to return an
* `Option` for structures that are guaranteed to be non-empty.
*
* @see [[minimumOptionBy]] for minimum instead of maximum.
* @see [[FoldableOps0.maximumByOption]] for minimum instead of maximum.
*/
def maximumOptionBy[B: Order](f: A => B)(implicit F: Foldable[F]): Option[A] =
def maximumByOption[B: Order](f: A => B)(implicit F: Foldable[F]): Option[A] =
F.maximumOption(fa)(Order.by(f))
}

Expand Down
4 changes: 2 additions & 2 deletions tests/src/test/scala/cats/tests/FoldableSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@ abstract class FoldableSuite[F[_]: Foldable](name: String)(implicit ArbFInt: Arb

test(s"Foldable[$name].maximumBy/minimumBy") {
forAll { (fa: F[Int], f: Int => Int) =>
val maxOpt = fa.maximumOptionBy(f).map(f)
val minOpt = fa.minimumOptionBy(f).map(f)
val maxOpt = fa.maximumByOption(f).map(f)
val minOpt = fa.minimumByOption(f).map(f)
val nelOpt = fa.toList.toNel
maxOpt should ===(nelOpt.map(_.maximumBy(f)).map(f))
maxOpt should ===(nelOpt.map(_.toList.maxBy(f)).map(f))
Expand Down

0 comments on commit bf5f51f

Please sign in to comment.