diff --git a/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala b/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala index 5591b8abded..218ab50a706 100644 --- a/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala +++ b/core/src/main/scala-2.13+/cats/data/NonEmptyLazyList.scala @@ -213,7 +213,7 @@ class NonEmptyLazyListOps[A](private val value: NonEmptyLazyList[A]) * Tests if some element is contained in this NonEmptyLazyList */ final def contains(a: A)(implicit A: Eq[A]): Boolean = - toLazyList.contains(a) + exists(A.eqv(a, _)) /** * Tests whether a predicate holds for all elements diff --git a/core/src/main/scala-2.13+/cats/instances/stream.scala b/core/src/main/scala-2.13+/cats/instances/stream.scala index ad01c35758b..cc8687100ed 100644 --- a/core/src/main/scala-2.13+/cats/instances/stream.scala +++ b/core/src/main/scala-2.13+/cats/instances/stream.scala @@ -104,7 +104,7 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { case Left(a) #:: tail => stack = fn(a) #::: tail advance() - case empty => + case _ => state = Right(None) } diff --git a/core/src/main/scala-2/src/main/scala/cats/arrow/FunctionKMacros.scala b/core/src/main/scala-2/src/main/scala/cats/arrow/FunctionKMacros.scala index 89dd8846bd4..51ed68ee7f6 100644 --- a/core/src/main/scala-2/src/main/scala/cats/arrow/FunctionKMacros.scala +++ b/core/src/main/scala-2/src/main/scala/cats/arrow/FunctionKMacros.scala @@ -22,7 +22,6 @@ package cats package arrow -import scala.language.experimental.macros import scala.reflect.macros.blackbox private[arrow] class FunctionKMacroMethods { diff --git a/core/src/main/scala-2/src/main/scala/cats/compat/targetName.scala b/core/src/main/scala-2/src/main/scala/cats/compat/targetName.scala index 44e0e795aaa..50ef43c2594 100644 --- a/core/src/main/scala-2/src/main/scala/cats/compat/targetName.scala +++ b/core/src/main/scala-2/src/main/scala/cats/compat/targetName.scala @@ -22,6 +22,7 @@ package cats.compat import scala.annotation.Annotation +import scala.annotation.nowarn // compat dummy so we can use targetName on scala 3 to get out of bincompat pickles -private[cats] class targetName(dummy: String) extends Annotation +private[cats] class targetName(@nowarn("cat=unused-params") dummy: String) extends Annotation diff --git a/core/src/main/scala/cats/ApplicativeError.scala b/core/src/main/scala/cats/ApplicativeError.scala index 847930d56e7..4c7eb925cb0 100644 --- a/core/src/main/scala/cats/ApplicativeError.scala +++ b/core/src/main/scala/cats/ApplicativeError.scala @@ -25,6 +25,7 @@ import cats.ApplicativeError.CatchOnlyPartiallyApplied import cats.data.{EitherT, Validated} import cats.data.Validated.{Invalid, Valid} +import scala.annotation.nowarn import scala.reflect.ClassTag import scala.util.control.NonFatal import scala.util.{Failure, Success, Try} @@ -353,7 +354,13 @@ object ApplicativeError { final private[cats] class CatchOnlyPartiallyApplied[T, F[_], E](private val F: ApplicativeError[F, E]) extends AnyVal { - def apply[A](f: => A)(implicit CT: ClassTag[T], NT: NotNull[T], ev: Throwable <:< E): F[A] = + + def apply[A](f: => A)(implicit + CT: ClassTag[T], + @nowarn("cat=unused-params") + NT: NotNull[T], + ev: Throwable <:< E + ): F[A] = try { F.pure(f) } catch { diff --git a/core/src/main/scala/cats/TraverseFilter.scala b/core/src/main/scala/cats/TraverseFilter.scala index 76628ac4088..d96eeaf7066 100644 --- a/core/src/main/scala/cats/TraverseFilter.scala +++ b/core/src/main/scala/cats/TraverseFilter.scala @@ -124,7 +124,12 @@ trait TraverseFilter[F[_]] extends FunctorFilter[F] { /** * Removes duplicate elements from a list, keeping only the first occurrence. - * This is usually faster than ordDistinct, especially for things that have a slow comparion (like String). + * This is usually faster than ordDistinct, especially for things that have a slow comparison (like String). + * + * @note the passed `Hash` typeclass is not currently in use. + * @todo replace `HashSet` from Scala library with one that can make use of the `Hash` typeclass + * instead of the Java's `hashCode` method. Consider a candidate implementation in + * [[https://github.com/typelevel/cats/pull/4185 PR#4185]]. */ def hashDistinct[A](fa: F[A])(implicit H: Hash[A]): F[A] = traverseFilter[State[HashSet[A], *], A, A](fa)(a => diff --git a/core/src/main/scala/cats/data/Const.scala b/core/src/main/scala/cats/data/Const.scala index 28626fa51a4..d6722f06910 100644 --- a/core/src/main/scala/cats/data/Const.scala +++ b/core/src/main/scala/cats/data/Const.scala @@ -23,6 +23,7 @@ package cats package data import cats.kernel.{CommutativeMonoid, CommutativeSemigroup, LowerBounded, UpperBounded} +import scala.annotation.nowarn /** * [[Const]] is a phantom type, it does not contain a value of its second type parameter `B` @@ -39,7 +40,7 @@ final case class Const[A, B](getConst: A) { def combine(that: Const[A, B])(implicit A: Semigroup[A]): Const[A, B] = Const(A.combine(getConst, that.getConst)) - def traverse[F[_], C](f: B => F[C])(implicit F: Applicative[F]): F[Const[A, C]] = + def traverse[F[_], C](@nowarn("cat=unused-params") f: B => F[C])(implicit F: Applicative[F]): F[Const[A, C]] = F.pure(retag[C]) def ===(that: Const[A, B])(implicit A: Eq[A]): Boolean = diff --git a/core/src/main/scala/cats/data/EitherT.scala b/core/src/main/scala/cats/data/EitherT.scala index bc59e634406..69932adccc2 100644 --- a/core/src/main/scala/cats/data/EitherT.scala +++ b/core/src/main/scala/cats/data/EitherT.scala @@ -986,7 +986,6 @@ abstract private[data] class EitherTInstances extends EitherTInstances1 { type F[x] = Nested[P.F, Validated[E, *], x] implicit val monadM: Monad[M] = P.monad - implicit val monadEither: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither def applicative: Applicative[Nested[P.F, Validated[E, *], *]] = cats.data.Nested.catsDataApplicativeForNested(P.applicative, Validated.catsDataApplicativeErrorForValidated) @@ -1017,7 +1016,6 @@ abstract private[data] class EitherTInstances extends EitherTInstances1 { type F[x] = Nested[P.F, Either[E, *], x] implicit val monadM: Monad[M] = P.monad - implicit val monadEither: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither def applicative: Applicative[Nested[P.F, Either[E, *], *]] = cats.data.Nested.catsDataApplicativeForNested(P.applicative, implicitly) @@ -1082,7 +1080,6 @@ abstract private[data] class EitherTInstances1 extends EitherTInstances2 { type F[x] = Nested[M, Validated[E, *], x] implicit val appValidated: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated - implicit val monadEither: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither def applicative: Applicative[Nested[M, Validated[E, *], *]] = cats.data.Nested.catsDataApplicativeForNested[M, Validated[E, *]] @@ -1154,14 +1151,14 @@ private[data] trait EitherTSemigroupK[F[_], L] extends SemigroupK[EitherT[F, L, implicit val F: Monad[F] def combineK[A](x: EitherT[F, L, A], y: EitherT[F, L, A]): EitherT[F, L, A] = EitherT(F.flatMap(x.value) { - case l @ Left(_) => y.value - case r @ Right(_) => F.pure(r) + case r: Right[L, A] => F.pure(r) + case _ => y.value }) override def combineKEval[A](x: EitherT[F, L, A], y: Eval[EitherT[F, L, A]]): Eval[EitherT[F, L, A]] = Eval.now(EitherT(F.flatMap(x.value) { - case l @ Left(_) => y.value.value - case r @ Right(_) => F.pure(r: Either[L, A]) + case r: Right[L, A] => F.pure(r) + case _ => y.value.value })) } diff --git a/core/src/main/scala/cats/data/Func.scala b/core/src/main/scala/cats/data/Func.scala index 6ca7327297f..7d274ee7ffd 100644 --- a/core/src/main/scala/cats/data/Func.scala +++ b/core/src/main/scala/cats/data/Func.scala @@ -113,7 +113,7 @@ sealed private[data] trait FuncApply[F[_], C] extends Apply[λ[α => Func[F, C, sealed private[data] trait FuncApplicative[F[_], C] extends Applicative[λ[α => Func[F, C, α]]] with FuncApply[F, C] { def F: Applicative[F] def pure[A](a: A): Func[F, C, A] = - Func.func(c => F.pure(a)) + Func.func(_ => F.pure(a)) } /** @@ -167,5 +167,5 @@ sealed private[data] trait AppFuncApplicative[F[_], C] extends Applicative[λ[α override def product[A, B](fa: AppFunc[F, C, A], fb: AppFunc[F, C, B]): AppFunc[F, C, (A, B)] = Func.appFunc[F, C, (A, B)](c => F.product(fa.run(c), fb.run(c)))(F) def pure[A](a: A): AppFunc[F, C, A] = - Func.appFunc[F, C, A](c => F.pure(a))(F) + Func.appFunc[F, C, A](_ => F.pure(a))(F) } diff --git a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala index 26b684ef540..de542ff40af 100644 --- a/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala +++ b/core/src/main/scala/cats/data/IndexedReaderWriterStateT.scala @@ -246,7 +246,7 @@ final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A](val runF: F[(E, SA) * Inspect a value from the input state, without modifying the state. */ def inspect[B](f: SB => B)(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, B] = - transform { (l, sb, a) => + transform { (l, sb, _) => (l, sb, f(sb)) } @@ -287,7 +287,7 @@ final class IndexedReaderWriterStateT[F[_], E, L, SA, SB, A](val runF: F[(E, SA) * Retrieve the value written to the log. */ def written(implicit F: Functor[F]): IndexedReaderWriterStateT[F, E, L, SA, SB, L] = - transform { (l, sb, a) => + transform { (l, sb, _) => (l, sb, l) } @@ -555,7 +555,11 @@ abstract private[data] class RWSFunctions { /** * Return `a` and an empty log without modifying the input state. */ - def apply[E, L: Monoid, S, A](f: (E, S) => (L, S, A)): ReaderWriterState[E, L, S, A] = + def apply[E, L, S, A](f: (E, S) => (L, S, A)): ReaderWriterState[E, L, S, A] = + ReaderWriterStateT.applyF(Now((e, s) => Now(f(e, s)))) + + @deprecated("2.8.0", "Use apply without the Monoid constraint") + protected def apply[E, L: Monoid, S, A](f: (E, S) => (L, S, A)): ReaderWriterState[E, L, S, A] = ReaderWriterStateT.applyF(Now((e, s) => Now(f(e, s)))) /** diff --git a/core/src/main/scala/cats/data/IndexedStateT.scala b/core/src/main/scala/cats/data/IndexedStateT.scala index 92ff65a2f58..683693785d3 100644 --- a/core/src/main/scala/cats/data/IndexedStateT.scala +++ b/core/src/main/scala/cats/data/IndexedStateT.scala @@ -483,7 +483,7 @@ sealed abstract private[data] class IndexedStateTContravariantMonoidal[F[_], S] implicit def G: Applicative[F] override def unit: IndexedStateT[F, S, S, Unit] = - IndexedStateT.applyF(G.pure((s: S) => F.trivial[(S, Unit)])) + IndexedStateT.applyF(G.pure((_: S) => F.trivial[(S, Unit)])) override def contramap[A, B](fa: IndexedStateT[F, S, S, A])(f: B => A): IndexedStateT[F, S, S, B] = contramap2(fa, trivial)(((a: A) => (a, a)).compose(f)) diff --git a/core/src/main/scala/cats/data/Ior.scala b/core/src/main/scala/cats/data/Ior.scala index 9c6def13d08..1b800e18a97 100644 --- a/core/src/main/scala/cats/data/Ior.scala +++ b/core/src/main/scala/cats/data/Ior.scala @@ -775,9 +775,9 @@ sealed abstract class Ior[+A, +B] extends Product with Serializable { final def ===[AA >: A, BB >: B](that: AA Ior BB)(implicit AA: Eq[AA], BB: Eq[BB]): Boolean = fold( - a => that.fold(a2 => AA.eqv(a, a2), b2 => false, (a2, b2) => false), - b => that.fold(a2 => false, b2 => BB.eqv(b, b2), (a2, b2) => false), - (a, b) => that.fold(a2 => false, b2 => false, (a2, b2) => AA.eqv(a, a2) && BB.eqv(b, b2)) + a => that.fold(a2 => AA.eqv(a, a2), _ => false, (_, _) => false), + b => that.fold(_ => false, b2 => BB.eqv(b, b2), (_, _) => false), + (a, b) => that.fold(_ => false, _ => false, (a2, b2) => AA.eqv(a, a2) && BB.eqv(b, b2)) ) final def compare[AA >: A, BB >: B](that: AA Ior BB)(implicit AA: Order[AA], BB: Order[BB]): Int = @@ -929,9 +929,9 @@ sealed abstract private[data] class IorInstances extends IorInstances0 { } case Ior.Left(e1) => ff match { - case Ior.Right(f) => Ior.Left(e1) - case Ior.Both(e2, f) => Ior.Left(E.combine(e2, e1)) + case Ior.Both(e2, _) => Ior.Left(E.combine(e2, e1)) case Ior.Left(e2) => Ior.Left(E.combine(e2, e1)) + case _ => Ior.Left(e1) } } } diff --git a/core/src/main/scala/cats/data/NonEmptySet.scala b/core/src/main/scala/cats/data/NonEmptySet.scala index 9b6526d2c27..71ff8721490 100644 --- a/core/src/main/scala/cats/data/NonEmptySet.scala +++ b/core/src/main/scala/cats/data/NonEmptySet.scala @@ -428,7 +428,7 @@ sealed abstract private[data] class NonEmptySetInstances extends NonEmptySetInst } sealed abstract private[data] class NonEmptySetInstances0 extends NonEmptySetInstances1 { - implicit def catsDataHashForNonEmptySet[A: Order: Hash]: Hash[NonEmptySet[A]] = + implicit def catsDataHashForNonEmptySet[A: Hash]: Hash[NonEmptySet[A]] = Hash[SortedSet[A]].asInstanceOf[Hash[NonEmptySet[A]]] } diff --git a/core/src/main/scala/cats/data/RepresentableStore.scala b/core/src/main/scala/cats/data/RepresentableStore.scala index 867e1dff40d..2a7efd016ae 100644 --- a/core/src/main/scala/cats/data/RepresentableStore.scala +++ b/core/src/main/scala/cats/data/RepresentableStore.scala @@ -95,19 +95,25 @@ final case class RepresentableStore[F[_], S, A](fa: F[A], index: S)(implicit R: object RepresentableStore { - implicit def catsDataRepresentableStoreComonad[F[_], S](implicit - R: Representable[F] - ): Comonad[RepresentableStore[F, S, *]] = - new Comonad[RepresentableStore[F, S, *]] { - override def extract[B](x: RepresentableStore[F, S, B]): B = - x.extract - - override def coflatMap[A, B]( - fa: RepresentableStore[F, S, A] - )(f: RepresentableStore[F, S, A] => B): RepresentableStore[F, S, B] = - fa.coflatten.map(f) - - override def map[A, B](fa: RepresentableStore[F, S, A])(f: A => B): RepresentableStore[F, S, B] = - fa.map(f) - } + implicit def catsDataRepresentableStoreComonadBinCompat[F[_], S]: Comonad[RepresentableStore[F, S, *]] = + new RepresentableStoreComonad[F, S] + + @deprecated("Use catsDataRepresentableStoreComonadBinCompat instead", "2.8.0") + def catsDataRepresentableStoreComonad[F[_], S](R: Representable[F]): Comonad[RepresentableStore[F, S, *]] = + new RepresentableStoreComonad[F, S] + + final private class RepresentableStoreComonad[F[_], S] private[RepresentableStore] + extends Comonad[RepresentableStore[F, S, *]] { + + override def extract[B](x: RepresentableStore[F, S, B]): B = + x.extract + + override def coflatMap[A, B]( + fa: RepresentableStore[F, S, A] + )(f: RepresentableStore[F, S, A] => B): RepresentableStore[F, S, B] = + fa.coflatten.map(f) + + override def map[A, B](fa: RepresentableStore[F, S, A])(f: A => B): RepresentableStore[F, S, B] = + fa.map(f) + } } diff --git a/core/src/main/scala/cats/data/Validated.scala b/core/src/main/scala/cats/data/Validated.scala index 847b9795369..ce3311dc587 100644 --- a/core/src/main/scala/cats/data/Validated.scala +++ b/core/src/main/scala/cats/data/Validated.scala @@ -25,6 +25,7 @@ package data import cats.data.Validated.{Invalid, Valid} import cats.kernel.CommutativeSemigroup +import scala.annotation.nowarn import scala.reflect.ClassTag import scala.util.{Failure, Success, Try} @@ -859,7 +860,11 @@ object Validated extends ValidatedInstances with ValidatedFunctions with Validat final private[data] class CatchOnlyPartiallyApplied[T](private val dummy: Boolean = true) extends AnyVal { /* Note: the NT parameter is not referenced at runtime, but serves a compile-time role. * See https://github.com/typelevel/cats/pull/1867/files#r138381991 for details. */ - def apply[A](f: => A)(implicit T: ClassTag[T], NT: NotNull[T]): Validated[T, A] = + def apply[A](f: => A)(implicit + T: ClassTag[T], + @nowarn("cat=unused-params") + NT: NotNull[T] + ): Validated[T, A] = try { valid(f) } catch { @@ -894,13 +899,13 @@ sealed abstract private[data] class ValidatedInstances extends ValidatedInstance fa match { case Invalid(e) => fb match { - case Invalid(e2) => Invalid(Semigroup[E].combine(e, e2)) case Valid(b) => Valid(f(Ior.right(b))) + case Invalid(e2) => Invalid(Semigroup[E].combine(e, e2)) } case Valid(a) => fb match { - case Invalid(e) => Valid(f(Ior.left(a))) - case Valid(b) => Valid(f(Ior.both(a, b))) + case Valid(b) => Valid(f(Ior.both(a, b))) + case _ => Valid(f(Ior.left(a))) } } } diff --git a/core/src/main/scala/cats/instances/either.scala b/core/src/main/scala/cats/instances/either.scala index 70c3b0ea718..26ad1f4c122 100644 --- a/core/src/main/scala/cats/instances/either.scala +++ b/core/src/main/scala/cats/instances/either.scala @@ -189,15 +189,15 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances { override def alignWith[B, C, D](fb: Either[A, B], fc: Either[A, C])(f: Ior[B, C] => D): Either[A, D] = fb match { - case left @ Left(a) => + case left: Left[A, B] => fc match { - case Left(_) => left.rightCast[D] case Right(c) => Right(f(Ior.right(c))) + case _ => left.rightCast[D] } case Right(b) => fc match { - case Left(a) => Right(f(Ior.left(b))) case Right(c) => Right(f(Ior.both(b, c))) + case _ => Right(f(Ior.left(b))) } } diff --git a/core/src/main/scala/cats/instances/map.scala b/core/src/main/scala/cats/instances/map.scala index 4eefa6a8ac7..9c3e1867df0 100644 --- a/core/src/main/scala/cats/instances/map.scala +++ b/core/src/main/scala/cats/instances/map.scala @@ -79,7 +79,7 @@ trait MapInstances extends cats.kernel.instances.MapInstances { fa.flatMap { case (k, a) => f(a).get(k).map((k, _)) } def unorderedFoldMap[A, B: CommutativeMonoid](fa: Map[K, A])(f: (A) => B) = - fa.foldLeft(Monoid[B].empty) { case (b, (k, a)) => Monoid[B].combine(b, f(a)) } + fa.foldLeft(Monoid[B].empty) { case (b, (_, a)) => Monoid[B].combine(b, f(a)) } def tailRecM[A, B](a: A)(f: A => Map[K, Either[A, B]]): Map[K, B] = { val bldr = Map.newBuilder[K, B] diff --git a/core/src/main/scala/cats/instances/sortedMap.scala b/core/src/main/scala/cats/instances/sortedMap.scala index 6454ffb6867..d6d1b867596 100644 --- a/core/src/main/scala/cats/instances/sortedMap.scala +++ b/core/src/main/scala/cats/instances/sortedMap.scala @@ -201,10 +201,7 @@ class SortedMapEq[K, V](implicit V: Eq[V], O: Order[K]) extends cats.kernel.inst @deprecated("Use cats.kernel.instances.SortedMapCommutativeMonoid", "2.0.0-RC2") class SortedMapCommutativeMonoid[K, V](implicit V: CommutativeSemigroup[V], O: Order[K]) extends SortedMapMonoid[K, V] - with CommutativeMonoid[SortedMap[K, V]] { - private[this] val underlying: CommutativeMonoid[SortedMap[K, V]] = - new cats.kernel.instances.SortedMapCommutativeMonoid[K, V] -} + with CommutativeMonoid[SortedMap[K, V]] @deprecated("Use cats.kernel.instances.SortedMapMonoid", "2.0.0-RC2") class SortedMapMonoid[K, V](implicit V: Semigroup[V], O: Order[K]) extends cats.kernel.instances.SortedMapMonoid[K, V] diff --git a/core/src/main/scala/cats/syntax/applicativeError.scala b/core/src/main/scala/cats/syntax/applicativeError.scala index ff12673bb6b..e81baaeeca3 100644 --- a/core/src/main/scala/cats/syntax/applicativeError.scala +++ b/core/src/main/scala/cats/syntax/applicativeError.scala @@ -24,15 +24,18 @@ package syntax import cats.data.{EitherT, Validated} +import scala.annotation.nowarn import scala.reflect.ClassTag trait ApplicativeErrorSyntax { implicit final def catsSyntaxApplicativeErrorId[E](e: E): ApplicativeErrorIdOps[E] = new ApplicativeErrorIdOps(e) - implicit final def catsSyntaxApplicativeError[F[_], E, A]( - fa: F[A] - )(implicit F: ApplicativeError[F, E]): ApplicativeErrorOps[F, E, A] = + implicit final def catsSyntaxApplicativeError[F[_], E, A](fa: F[A])(implicit + // Although not used directly but helps the compiler to deduce type `E`. + @nowarn("cat=unused-params") + F: ApplicativeError[F, E] + ): ApplicativeErrorOps[F, E, A] = new ApplicativeErrorOps[F, E, A](fa) } diff --git a/core/src/main/scala/cats/syntax/either.scala b/core/src/main/scala/cats/syntax/either.scala index 1c4a97e8a4e..220c0ce298e 100644 --- a/core/src/main/scala/cats/syntax/either.scala +++ b/core/src/main/scala/cats/syntax/either.scala @@ -24,6 +24,7 @@ package syntax import cats.data._ +import scala.annotation.nowarn import scala.reflect.ClassTag import scala.util.{Failure, Success, Try} import EitherSyntax._ @@ -47,7 +48,11 @@ object EitherSyntax { * Uses the [[http://typelevel.org/cats/guidelines.html#partially-applied-type-params Partially Applied Type Params technique]] for ergonomics. */ final private[syntax] class CatchOnlyPartiallyApplied[T](private val dummy: Boolean = true) extends AnyVal { - def apply[A](f: => A)(implicit CT: ClassTag[T], NT: NotNull[T]): Either[T, A] = + def apply[A](f: => A)(implicit + CT: ClassTag[T], + @nowarn("cat=unused-params") + NT: NotNull[T] + ): Either[T, A] = try { Right(f) } catch { @@ -355,7 +360,7 @@ final class EitherOps[A, B](private val eab: Either[A, B]) extends AnyVal { def liftTo[F[_]](implicit F: ApplicativeError[F, _ >: A]): F[B] = F.fromEither(eab) } -final class EitherObjectOps(private val either: Either.type) extends AnyVal { +final class EitherObjectOps(private val either: Either.type) extends AnyVal with EitherObjectOpsBinCompat { def left[A, B](a: A): Either[A, B] = Left(a) def right[A, B](b: B): Either[A, B] = Right(b) @@ -366,7 +371,8 @@ final class EitherObjectOps(private val either: Either.type) extends AnyVal { def leftNes[A, B](a: A)(implicit O: Order[A]): EitherNes[A, B] = Left(NonEmptySet.one(a)) - def rightNes[A, B](b: B)(implicit O: Order[B]): EitherNes[A, B] = Right(b) + @deprecated("2.8.0", "Use rightNes without Order constraint") + protected def rightNes[A, B](b: B)(implicit O: Order[B]): EitherNes[A, B] = Right(b) def leftNel[A, B](a: A): EitherNel[A, B] = Left(NonEmptyList.one(a)) @@ -418,6 +424,10 @@ final class EitherObjectOps(private val either: Either.type) extends AnyVal { def unit[A]: Either[A, Unit] = EitherUtil.unit } +sealed private[syntax] trait EitherObjectOpsBinCompat extends Any { self: EitherObjectOps => + def rightNes[A, B](b: B): EitherNes[A, B] = Right(b) +} + final class LeftOps[A, B](private val left: Left[A, B]) extends AnyVal { /** diff --git a/tests/shared/src/test/scala/cats/tests/RepresentableStoreSuite.scala b/tests/shared/src/test/scala/cats/tests/RepresentableStoreSuite.scala index b204a439b8c..65dfaa892b1 100644 --- a/tests/shared/src/test/scala/cats/tests/RepresentableStoreSuite.scala +++ b/tests/shared/src/test/scala/cats/tests/RepresentableStoreSuite.scala @@ -37,7 +37,7 @@ class RepresentableStoreSuite extends CatsSuite { { implicit val pairComonad: Comonad[RepresentableStore[λ[P => (P, P)], Boolean, *]] = - RepresentableStore.catsDataRepresentableStoreComonad[λ[P => (P, P)], Boolean] + RepresentableStore.catsDataRepresentableStoreComonadBinCompat[λ[P => (P, P)], Boolean] implicit val arbStore: Arbitrary[RepresentableStore[λ[P => (P, P)], Boolean, Int]] = catsLawsArbitraryForRepresentableStore[λ[P => (P, P)], Boolean, Int] implicit val cogenStore: Cogen[RepresentableStore[λ[P => (P, P)], Boolean, Int]] =