From d35788e5d561aa802771afe52a953c2b0290a2bd Mon Sep 17 00:00:00 2001 From: Valeriy Avanesov Date: Tue, 11 Aug 2020 19:16:51 +0200 Subject: [PATCH] Comments on NonEmptyReducible not being a typeclass `NonEmptyReducible` is not a typeclass and should not be used outside of Cats. Thus, the corresponding comments are added to the `NonEmptyReducible` along with `catsDataInstancesForNonEmptyVector` and `catsDataInstancesForNonEmptyList` implementing it. --- core/src/main/scala/cats/Reducible.scala | 3 +++ core/src/main/scala/cats/data/NonEmptyList.scala | 6 ++++++ core/src/main/scala/cats/data/NonEmptyVector.scala | 6 ++++++ 3 files changed, 15 insertions(+) diff --git a/core/src/main/scala/cats/Reducible.scala b/core/src/main/scala/cats/Reducible.scala index b67ae82f80..2065307ae9 100644 --- a/core/src/main/scala/cats/Reducible.scala +++ b/core/src/main/scala/cats/Reducible.scala @@ -369,6 +369,9 @@ object Reducible { * * This class can be used on any type where the first value (`A`) and * the "rest" of the values (`G[A]`) can be easily found. + * + * This class is only a helper, does not define a typeclass and should not be used outside of Cats. + * Also see the discussion: PR #3541 and issue #3069. */ abstract class NonEmptyReducible[F[_], G[_]](implicit G: Foldable[G]) extends Reducible[F] { def split[A](fa: F[A]): (A, G[A]) diff --git a/core/src/main/scala/cats/data/NonEmptyList.scala b/core/src/main/scala/cats/data/NonEmptyList.scala index ffaf88ee3e..d9f0be45e7 100644 --- a/core/src/main/scala/cats/data/NonEmptyList.scala +++ b/core/src/main/scala/cats/data/NonEmptyList.scala @@ -528,6 +528,12 @@ object NonEmptyList extends NonEmptyListInstances { sealed abstract private[data] class NonEmptyListInstances extends NonEmptyListInstances0 { + /** + * This is not a bug. The declared type of `catsDataInstancesForNonEmptyList` intentionally ignores + * `NonEmptyReducible` trait for it not being a typeclass. + * + * Also see the discussion: PR #3541 and issue #3069. + */ implicit val catsDataInstancesForNonEmptyList : SemigroupK[NonEmptyList] with Bimonad[NonEmptyList] with NonEmptyTraverse[NonEmptyList] with Align[NonEmptyList] = new NonEmptyReducible[NonEmptyList, List] diff --git a/core/src/main/scala/cats/data/NonEmptyVector.scala b/core/src/main/scala/cats/data/NonEmptyVector.scala index 3ddefd7d7d..0dee3d8b59 100644 --- a/core/src/main/scala/cats/data/NonEmptyVector.scala +++ b/core/src/main/scala/cats/data/NonEmptyVector.scala @@ -332,6 +332,12 @@ final class NonEmptyVector[+A] private (val toVector: Vector[A]) @suppressUnusedImportWarningForScalaVersionSpecific sealed abstract private[data] class NonEmptyVectorInstances { + /** + * This is not a bug. The declared type of `catsDataInstancesForNonEmptyVector` intentionally ignores + * `NonEmptyReducible` trait for it not being a typeclass. + * + * Also see the discussion: PR #3541 and issue #3069. + */ implicit val catsDataInstancesForNonEmptyVector: SemigroupK[NonEmptyVector] with Bimonad[NonEmptyVector] with NonEmptyTraverse[NonEmptyVector]