Skip to content

Commit 5e78f33

Browse files
committed
Simplify type signature of distinctBy
1 parent e9b342f commit 5e78f33

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,10 @@ class NonEmptyLazyListOps[A](private val value: NonEmptyLazyList[A])
347347
*/
348348
override def distinct[AA >: A](implicit O: Order[AA]): NonEmptyLazyList[AA] = distinctBy(identity[AA])
349349

350-
override def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NonEmptyLazyList[AA] = {
350+
override def distinctBy[B](f: A => B)(implicit O: Order[B]): NonEmptyLazyList[A] = {
351351
implicit val ord: Ordering[B] = O.toOrdering
352352

353-
val buf = LazyList.newBuilder[AA]
353+
val buf = LazyList.newBuilder[A]
354354
toLazyList.foldLeft(TreeSet.empty[B]) { (elementsSoFar, a) =>
355355
val b = f(a)
356356
if (elementsSoFar(b)) elementsSoFar

core/src/main/scala/cats/data/NonEmptyChain.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ class NonEmptyChainOps[A](private val value: NonEmptyChain[A])
605605
final def distinct[AA >: A](implicit O: Order[AA]): NonEmptyChain[AA] =
606606
distinctBy(identity[AA])
607607

608-
final def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NonEmptyChain[AA] =
608+
final def distinctBy[B](f: A => B)(implicit O: Order[B]): NonEmptyChain[A] =
609609
create(toChain.distinctBy[B](f))
610610

611611
final def sortBy[B](f: A => B)(implicit B: Order[B]): NonEmptyChain[A] = create(toChain.sortBy(f))

core/src/main/scala/cats/data/NonEmptyCollection.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private[cats] trait NonEmptyCollection[+A, U[+_], NE[+_]] extends Any {
5252
def zipWithIndex: NE[(A, Int)]
5353

5454
def distinct[AA >: A](implicit O: Order[AA]): NE[AA]
55-
def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NE[AA]
55+
def distinctBy[B](f: A => B)(implicit O: Order[B]): NE[A]
5656
def sortBy[B](f: A => B)(implicit B: Order[B]): NE[A]
5757
def sorted[AA >: A](implicit AA: Order[AA]): NE[AA]
5858
def groupByNem[B](f: A => B)(implicit B: Order[B]): NonEmptyMap[B, NE[A]]

core/src/main/scala/cats/data/NonEmptyList.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ final case class NonEmptyList[+A](head: A, tail: List[A]) extends NonEmptyCollec
342342
*/
343343
override def distinct[AA >: A](implicit O: Order[AA]): NonEmptyList[AA] = distinctBy(identity[AA])
344344

345-
override def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NonEmptyList[AA] = {
345+
override def distinctBy[B](f: A => B)(implicit O: Order[B]): NonEmptyList[A] = {
346346
implicit val ord: Ordering[B] = O.toOrdering
347347

348-
val buf = ListBuffer.empty[AA]
348+
val buf = ListBuffer.empty[A]
349349
tail.foldLeft(TreeSet(f(head): B)) { (elementsSoFar, a) =>
350350
val b = f(a)
351351
if (elementsSoFar(b)) elementsSoFar

core/src/main/scala/cats/data/NonEmptySeq.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ final class NonEmptySeq[+A] private (val toSeq: Seq[A]) extends AnyVal with NonE
238238
*/
239239
override def distinct[AA >: A](implicit O: Order[AA]): NonEmptySeq[AA] = distinctBy(identity[AA])
240240

241-
override def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NonEmptySeq[AA] = {
241+
override def distinctBy[B](f: A => B)(implicit O: Order[B]): NonEmptySeq[A] = {
242242
implicit val ord: Ordering[B] = O.toOrdering
243243

244-
val buf = Seq.newBuilder[AA]
244+
val buf = Seq.newBuilder[A]
245245
tail.foldLeft(TreeSet(f(head): B)) { (elementsSoFar, a) =>
246246
val b = f(a)
247247
if (elementsSoFar(b)) elementsSoFar

core/src/main/scala/cats/data/NonEmptyVector.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A])
248248
*/
249249
override def distinct[AA >: A](implicit O: Order[AA]): NonEmptyVector[AA] = distinctBy(identity[AA])
250250

251-
override def distinctBy[AA >: A, B](f: A => B)(implicit O: Order[B]): NonEmptyVector[AA] = {
251+
override def distinctBy[B](f: A => B)(implicit O: Order[B]): NonEmptyVector[A] = {
252252
implicit val ord: Ordering[B] = O.toOrdering
253253

254-
val buf = Vector.newBuilder[AA]
254+
val buf = Vector.newBuilder[A]
255255
tail.foldLeft(TreeSet(f(head): B)) { (elementsSoFar, a) =>
256256
val b = f(a)
257257
if (elementsSoFar(b)) elementsSoFar

tests/shared/src/test/scala-2.13+/cats/tests/NonEmptyLazyListSuite.scala

-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class NonEmptyLazyListSuite extends NonEmptyCollectionSuite[LazyList, NonEmptyLa
4949
checkAll(s"NonEmptyLazyList[Int]", HashTests[NonEmptyLazyList[Int]].hash)
5050
checkAll(s"Hash[NonEmptyLazyList[Int]]", SerializableTests.serializable(Hash[NonEmptyLazyList[Int]]))
5151

52-
checkAll("NonEmptyLazyList[Int]", NonEmptyAlternativeTests[NonEmptyLazyList].nonEmptyAlternative[Int, Int, Int])
5352
checkAll("NonEmptyLazyList[Int]", NonEmptyAlternativeTests[NonEmptyLazyList].nonEmptyAlternative[Int, Int, Int])
5453
checkAll("NonEmptyAlternative[NonEmptyLazyList]",
5554
SerializableTests.serializable(NonEmptyAlternative[NonEmptyLazyList])

0 commit comments

Comments
 (0)