Skip to content
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

Comments on NonEmptyReducible not being a typeclass #3562

Merged
merged 1 commit into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/src/main/scala/cats/Reducible.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/scala/cats/data/NonEmptyList.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/scala/cats/data/NonEmptyVector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down