From 65433840283da5513a6d3ea5cce082596d9246c9 Mon Sep 17 00:00:00 2001 From: Cody Allen Date: Tue, 14 Jun 2016 08:47:38 -0400 Subject: [PATCH] Yet some more uniquifying of implicit names I think this is the last of the implicit names for #1061. --- core/src/main/scala/cats/Eval.scala | 14 +++--- core/src/main/scala/cats/NotNull.scala | 4 +- core/src/main/scala/cats/Show.scala | 2 +- core/src/main/scala/cats/Trivial.scala | 2 +- core/src/main/scala/cats/Unapply.scala | 20 ++++---- core/src/main/scala/cats/data/Func.scala | 2 +- core/src/main/scala/cats/data/IdT.scala | 14 +++--- core/src/main/scala/cats/data/Nested.scala | 32 ++++++------- core/src/main/scala/cats/data/OneAnd.scala | 2 +- core/src/main/scala/cats/data/Validated.scala | 6 +-- core/src/main/scala/cats/data/XorT.scala | 2 +- .../main/scala/cats/functor/Invariant.scala | 4 +- core/src/main/scala/cats/package.scala | 2 +- free/src/main/scala/cats/free/Coyoneda.scala | 2 +- free/src/main/scala/cats/free/Free.scala | 4 +- free/src/main/scala/cats/free/Inject.scala | 6 +-- free/src/main/scala/cats/free/Yoneda.scala | 2 +- free/src/test/scala/cats/free/FreeTests.scala | 2 +- .../main/scala/cats/kernel/laws/package.scala | 7 --- kernel/src/main/scala/cats/kernel/Eq.scala | 2 +- kernel/src/main/scala/cats/kernel/Order.scala | 2 +- .../main/scala/cats/kernel/PartialOrder.scala | 2 +- .../cats/laws/discipline/Arbitrary.scala | 46 +++++++++---------- .../main/scala/cats/laws/discipline/Eq.scala | 18 +++----- .../scala/cats/laws/discipline/package.scala | 2 +- .../test/scala/cats/tests/CategoryTests.scala | 2 +- .../scala/cats/tests/CokleisliTests.scala | 8 ++-- .../test/scala/cats/tests/ComposeTest.scala | 2 +- .../test/scala/cats/tests/ConstTests.scala | 2 +- .../scala/cats/tests/MonadCombineTests.scala | 2 +- .../test/scala/cats/tests/NestedTests.scala | 18 ++++---- 31 files changed, 112 insertions(+), 123 deletions(-) diff --git a/core/src/main/scala/cats/Eval.scala b/core/src/main/scala/cats/Eval.scala index a56e6215bf..a3833fa0aa 100644 --- a/core/src/main/scala/cats/Eval.scala +++ b/core/src/main/scala/cats/Eval.scala @@ -295,7 +295,7 @@ object Eval extends EvalInstances { private[cats] trait EvalInstances extends EvalInstances0 { - implicit val evalBimonad: Bimonad[Eval] with MonadRec[Eval] = + implicit val catsBimonadForEval: Bimonad[Eval] with MonadRec[Eval] = new Bimonad[Eval] with MonadRec[Eval] { override def map[A, B](fa: Eval[A])(f: A => B): Eval[B] = fa.map(f) def pure[A](a: A): Eval[A] = Now(a) @@ -310,35 +310,35 @@ private[cats] trait EvalInstances extends EvalInstances0 { }) } - implicit def evalOrder[A: Order]: Order[Eval[A]] = + implicit def catsOrderForEval[A: Order]: Order[Eval[A]] = new Order[Eval[A]] { def compare(lx: Eval[A], ly: Eval[A]): Int = lx.value compare ly.value } - implicit def evalGroup[A: Group]: Group[Eval[A]] = + implicit def catsGroupForEval[A: Group]: Group[Eval[A]] = new EvalGroup[A] { val algebra: Group[A] = Group[A] } } private[cats] trait EvalInstances0 extends EvalInstances1 { - implicit def evalPartialOrder[A: PartialOrder]: PartialOrder[Eval[A]] = + implicit def catsPartialOrderForEval[A: PartialOrder]: PartialOrder[Eval[A]] = new PartialOrder[Eval[A]] { def partialCompare(lx: Eval[A], ly: Eval[A]): Double = lx.value partialCompare ly.value } - implicit def evalMonoid[A: Monoid]: Monoid[Eval[A]] = + implicit def catsMonoidForEval[A: Monoid]: Monoid[Eval[A]] = new EvalMonoid[A] { val algebra = Monoid[A] } } private[cats] trait EvalInstances1 { - implicit def evalEq[A: Eq]: Eq[Eval[A]] = + implicit def catsEqForEval[A: Eq]: Eq[Eval[A]] = new Eq[Eval[A]] { def eqv(lx: Eval[A], ly: Eval[A]): Boolean = lx.value === ly.value } - implicit def evalSemigroup[A: Semigroup]: Semigroup[Eval[A]] = + implicit def catsSemigroupForEval[A: Semigroup]: Semigroup[Eval[A]] = new EvalSemigroup[A] { val algebra = Semigroup[A] } } diff --git a/core/src/main/scala/cats/NotNull.scala b/core/src/main/scala/cats/NotNull.scala index fba9975b59..5cf16b5e02 100644 --- a/core/src/main/scala/cats/NotNull.scala +++ b/core/src/main/scala/cats/NotNull.scala @@ -20,7 +20,7 @@ object NotNull { implicit def `If you are seeing this, you probably need to add an explicit type parameter somewhere, because Null is being inferred.`: NotNull[Null] = throw ambiguousException - implicit def ambiguousNull2: NotNull[Null] = throw ambiguousException + implicit def catsAmbiguousNotNullNull2: NotNull[Null] = throw ambiguousException - implicit def notNull[A]: NotNull[A] = singleton.asInstanceOf[NotNull[A]] + implicit def catsNotNullForA[A]: NotNull[A] = singleton.asInstanceOf[NotNull[A]] } diff --git a/core/src/main/scala/cats/Show.scala b/core/src/main/scala/cats/Show.scala index 214ad82ceb..e09b9c85fb 100644 --- a/core/src/main/scala/cats/Show.scala +++ b/core/src/main/scala/cats/Show.scala @@ -25,7 +25,7 @@ object Show { def show(a: A): String = a.toString } - implicit val showContravariant: Contravariant[Show] = new Contravariant[Show] { + implicit val catsContravariantForShow: Contravariant[Show] = new Contravariant[Show] { def contramap[A, B](fa: Show[A])(f: B => A): Show[B] = show[B](fa.show _ compose f) } diff --git a/core/src/main/scala/cats/Trivial.scala b/core/src/main/scala/cats/Trivial.scala index 1ad335d8a5..1f8ed629c9 100644 --- a/core/src/main/scala/cats/Trivial.scala +++ b/core/src/main/scala/cats/Trivial.scala @@ -19,5 +19,5 @@ object Trivial { type P3[A, B, C] = Trivial type P3H1[F[_], A, B, C] = Trivial - implicit val manifest: Trivial = new Trivial {} + implicit val catsTrivialInstance: Trivial = new Trivial {} } diff --git a/core/src/main/scala/cats/Unapply.scala b/core/src/main/scala/cats/Unapply.scala index 9949c73cdd..c47b34213e 100644 --- a/core/src/main/scala/cats/Unapply.scala +++ b/core/src/main/scala/cats/Unapply.scala @@ -39,7 +39,7 @@ object Unapply extends Unapply2Instances { type A = AA } - implicit def unapply1[TC[_[_]], F[_], AA](implicit tc: TC[F]) + implicit def catsUnapply1[TC[_[_]], F[_], AA](implicit tc: TC[F]) : Aux1[TC,F[AA],F,AA] = new Unapply[TC,F[AA]] { type M[X] = F[X] @@ -80,14 +80,14 @@ private[cats] sealed abstract class Unapply2Instances extends Unapply3Instances } - implicit def unapply2left[TC[_[_]], F[_,_], AA, B](implicit tc: TC[F[?,B]]): Aux2Left[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { + implicit def catsUnapply2left[TC[_[_]], F[_,_], AA, B](implicit tc: TC[F[?,B]]): Aux2Left[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { type M[X] = F[X, B] type A = AA def TC: TC[F[?, B]] = tc def subst: F[AA, B] => M[A] = identity } - implicit def unapply2right[TC[_[_]], F[_,_], AA, B](implicit tc: TC[F[AA,?]]): Aux2Right[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { + implicit def catsUnapply2right[TC[_[_]], F[_,_], AA, B](implicit tc: TC[F[AA,?]]): Aux2Right[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { type M[X] = F[AA, X] type A = B def TC: TC[F[AA, ?]] = tc @@ -95,14 +95,14 @@ private[cats] sealed abstract class Unapply2Instances extends Unapply3Instances } - implicit def unapply2leftK[TC[_[_]], F[_,_[_]], AA, B[_]](implicit tc: TC[F[?,B]]): Aux2LeftK[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { + implicit def catsUnapply2leftK[TC[_[_]], F[_,_[_]], AA, B[_]](implicit tc: TC[F[?,B]]): Aux2LeftK[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { type M[X] = F[X, B] type A = AA def TC: TC[F[?, B]] = tc def subst: F[AA, B] => M[A] = identity } - implicit def unapply2rightK[TC[_[_]], F[_[_],_], AA[_], B](implicit tc: TC[F[AA,?]]): Aux2RightK[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { + implicit def catsUnapply2rightK[TC[_[_]], F[_[_],_], AA[_], B](implicit tc: TC[F[AA,?]]): Aux2RightK[TC,F[AA,B], F, AA, B] = new Unapply[TC, F[AA,B]] { type M[X] = F[AA, X] type A = B def TC: TC[F[AA, ?]] = tc @@ -114,14 +114,14 @@ private[cats] sealed abstract class Unapply2Instances extends Unapply3Instances // STEW: I'm not sure why these Nothing cases are needed and aren't // just caught by the generic cases, I'd love for someone to figure // that out and report back. - implicit def unapply2leftN[TC[_[_]], F[_,+_], AA](implicit tc: TC[F[?,Nothing]]): Aux2Left[TC,F[AA,Nothing], F, AA, Nothing] = new Unapply[TC, F[AA,Nothing]] { + implicit def catsUnapply2leftN[TC[_[_]], F[_,+_], AA](implicit tc: TC[F[?,Nothing]]): Aux2Left[TC,F[AA,Nothing], F, AA, Nothing] = new Unapply[TC, F[AA,Nothing]] { type M[X] = F[X, Nothing] type A = AA def TC: TC[F[?, Nothing]] = tc def subst: F[AA, Nothing] => M[A] = identity } - implicit def unapply2rightN[TC[_[_]], F[+_,_], B](implicit tc: TC[F[Nothing,?]]): Aux2Right[TC,F[Nothing,B], F, Nothing, B] = new Unapply[TC, F[Nothing,B]] { + implicit def catsUnapply2rightN[TC[_[_]], F[+_,_], B](implicit tc: TC[F[Nothing,?]]): Aux2Right[TC,F[Nothing,B], F, Nothing, B] = new Unapply[TC, F[Nothing,B]] { type M[X] = F[Nothing, X] type A = B def TC: TC[F[Nothing, ?]] = tc @@ -155,14 +155,14 @@ private[cats] sealed abstract class Unapply3Instances { } - implicit def unapply3MTLeft[TC[_[_]], F[_[_],_,_], AA[_], B, C](implicit tc: TC[F[AA,?,C]]): Aux3MTLeft[TC,F[AA, B, C], F, AA, B, C] = new Unapply[TC, F[AA,B,C]] { + implicit def catsUnapply3MTLeft[TC[_[_]], F[_[_],_,_], AA[_], B, C](implicit tc: TC[F[AA,?,C]]): Aux3MTLeft[TC,F[AA, B, C], F, AA, B, C] = new Unapply[TC, F[AA,B,C]] { type M[X] = F[AA, X, C] type A = B def TC: TC[F[AA, ?, C]] = tc def subst: F[AA, B, C] => M[A] = identity } - implicit def unapply3MTright[TC[_[_]], F[_[_],_,_], AA[_], B, C](implicit tc: TC[F[AA,B,?]]): Aux3MTRight[TC,F[AA,B,C], F, AA, B, C] = new Unapply[TC, F[AA,B,C]] { + implicit def catsUnapply3MTright[TC[_[_]], F[_[_],_,_], AA[_], B, C](implicit tc: TC[F[AA,B,?]]): Aux3MTRight[TC,F[AA,B,C], F, AA, B, C] = new Unapply[TC, F[AA,B,C]] { type M[X] = F[AA, B, X] type A = C def TC: TC[F[AA, B, ?]] = tc @@ -174,7 +174,7 @@ private[cats] sealed abstract class Unapply3Instances { type A = C } - implicit def unapply3Nested[TC[_[_]], MA, F[_[_], _[_], _], AA[_], BB[_], C](implicit tc: TC[F[AA, BB, ?]]): Aux3Nested[TC, F[AA, BB, C], F, AA, BB, C] = new Unapply[TC, F[AA, BB, C]] { + implicit def catsUnapply3Nested[TC[_[_]], MA, F[_[_], _[_], _], AA[_], BB[_], C](implicit tc: TC[F[AA, BB, ?]]): Aux3Nested[TC, F[AA, BB, C], F, AA, BB, C] = new Unapply[TC, F[AA, BB, C]] { type M[X] = F[AA, BB, X] type A = C def TC: TC[F[AA, BB, ?]] = tc diff --git a/core/src/main/scala/cats/data/Func.scala b/core/src/main/scala/cats/data/Func.scala index de64c0f941..45b18eeac9 100644 --- a/core/src/main/scala/cats/data/Func.scala +++ b/core/src/main/scala/cats/data/Func.scala @@ -88,7 +88,7 @@ sealed abstract class AppFunc[F[_], A, B] extends Func[F, A, B] { self => } def compose[G[_], C](g: AppFunc[G, C, A]): AppFunc[Nested[G, F, ?], C, B] = { - implicit val gfApplicative: Applicative[Nested[G, F, ?]] = Nested.nestedApplicative[G, F](g.F, F) + implicit val gfApplicative: Applicative[Nested[G, F, ?]] = Nested.catsDataApplicativeForNested[G, F](g.F, F) Func.appFunc[Nested[G, F, ?], C, B]({ c: C => Nested(g.F.map(g.run(c))(self.run)) }) diff --git a/core/src/main/scala/cats/data/IdT.scala b/core/src/main/scala/cats/data/IdT.scala index 97cb261960..47b2da4bc6 100644 --- a/core/src/main/scala/cats/data/IdT.scala +++ b/core/src/main/scala/cats/data/IdT.scala @@ -70,7 +70,7 @@ private[data] sealed trait IdTTraverse[F[_]] extends Traverse[IdT[F, ?]] with Id } private[data] sealed abstract class IdTInstances1 { - implicit def idTFunctor[F[_]](implicit F: Functor[F]): Functor[IdT[F, ?]] = + implicit def catsDataFunctorForIdT[F[_]](implicit F: Functor[F]): Functor[IdT[F, ?]] = new IdTFunctor[F] { implicit val F0: Functor[F] = F } @@ -78,30 +78,30 @@ private[data] sealed abstract class IdTInstances1 { private[data] sealed abstract class IdTInstances0 extends IdTInstances1 { - implicit def idTMonad[F[_]](implicit F: Monad[F]): Monad[IdT[F, ?]] = + implicit def catsDataMonadForIdT[F[_]](implicit F: Monad[F]): Monad[IdT[F, ?]] = new IdTMonad[F] { implicit val F0: Monad[F] = F } - implicit def idTFoldable[F[_]](implicit F: Foldable[F]): Foldable[IdT[F, ?]] = + implicit def catsDataFoldableForIdT[F[_]](implicit F: Foldable[F]): Foldable[IdT[F, ?]] = new IdTFoldable[F] { implicit val F0: Foldable[F] = F } - implicit def idTOrder[F[_], A](implicit F: Order[F[A]]): Order[IdT[F, A]] = + implicit def catsDataOrderForIdT[F[_], A](implicit F: Order[F[A]]): Order[IdT[F, A]] = F.on(_.value) } private[data] sealed abstract class IdTInstances extends IdTInstances0 { - implicit def idTTraverse[F[_]](implicit F: Traverse[F]): Traverse[IdT[F, ?]] = + implicit def catsDataTraverseForIdT[F[_]](implicit F: Traverse[F]): Traverse[IdT[F, ?]] = new IdTTraverse[F] { implicit val F0: Traverse[F] = F } - implicit def idTEq[F[_], A](implicit F: Eq[F[A]]): Eq[IdT[F, A]] = + implicit def catsDataEqForIdT[F[_], A](implicit F: Eq[F[A]]): Eq[IdT[F, A]] = F.on(_.value) - implicit def idTShow[F[_], A](implicit F: Show[F[A]]): Show[IdT[F, A]] = + implicit def catsDataShowForIdT[F[_], A](implicit F: Show[F[A]]): Show[IdT[F, A]] = functor.Contravariant[Show].contramap(F)(_.value) } diff --git a/core/src/main/scala/cats/data/Nested.scala b/core/src/main/scala/cats/data/Nested.scala index 7dbdf00ee8..49be416b04 100644 --- a/core/src/main/scala/cats/data/Nested.scala +++ b/core/src/main/scala/cats/data/Nested.scala @@ -28,10 +28,10 @@ final case class Nested[F[_], G[_], A](value: F[G[A]]) object Nested extends NestedInstances private[data] sealed abstract class NestedInstances extends NestedInstances1 { - implicit def nestedEq[F[_], G[_], A](implicit FGA: Eq[F[G[A]]]): Eq[Nested[F, G, A]] = + implicit def catsDataEqForNested[F[_], G[_], A](implicit FGA: Eq[F[G[A]]]): Eq[Nested[F, G, A]] = FGA.on(_.value) - implicit def nestedTraverse[F[_]: Traverse, G[_]: Traverse]: Traverse[Nested[F, G, ?]] = + implicit def catsDataTraverseForNested[F[_]: Traverse, G[_]: Traverse]: Traverse[Nested[F, G, ?]] = new Traverse[Nested[F, G, ?]] { val instance = Traverse[F].compose[G] @@ -53,7 +53,7 @@ private[data] sealed abstract class NestedInstances extends NestedInstances1 { } private[data] sealed abstract class NestedInstances1 extends NestedInstances2 { - implicit def nestedReducible[F[_]: Reducible, G[_]: Reducible]: Reducible[Nested[F, G, ?]] = + implicit def catsDataReducibleForNested[F[_]: Reducible, G[_]: Reducible]: Reducible[Nested[F, G, ?]] = new Reducible[Nested[F, G, ?]] { val instance = Reducible[F].compose[G] @@ -70,7 +70,7 @@ private[data] sealed abstract class NestedInstances1 extends NestedInstances2 { instance.foldRight(fga.value, lb)(f) } - implicit def nestedContravariant[F[_]: Contravariant, G[_]: Contravariant]: Functor[Nested[F, G, ?]] = + implicit def catsDataContravariantForNested[F[_]: Contravariant, G[_]: Contravariant]: Functor[Nested[F, G, ?]] = new Functor[Nested[F, G, ?]] { val instance = Contravariant[F].compose[G] @@ -81,7 +81,7 @@ private[data] sealed abstract class NestedInstances1 extends NestedInstances2 { } private[data] sealed abstract class NestedInstances2 extends NestedInstances3 { - implicit def nestedFoldable[F[_]: Foldable, G[_]: Foldable]: Foldable[Nested[F, G, ?]] = + implicit def catsDataFoldableForNested[F[_]: Foldable, G[_]: Foldable]: Foldable[Nested[F, G, ?]] = new Foldable[Nested[F, G, ?]] { val instance = Foldable[F].compose[G] @@ -93,7 +93,7 @@ private[data] sealed abstract class NestedInstances2 extends NestedInstances3 { } - implicit def nestedContravariantCovariant[F[_]: Contravariant, G[_]: Functor]: Contravariant[Nested[F, G, ?]] = + implicit def catsDataContravariantForCovariantNested[F[_]: Contravariant, G[_]: Functor]: Contravariant[Nested[F, G, ?]] = new Contravariant[Nested[F, G, ?]] { val instance = Contravariant[F].composeFunctor[G] @@ -103,7 +103,7 @@ private[data] sealed abstract class NestedInstances2 extends NestedInstances3 { } private[data] sealed abstract class NestedInstances3 extends NestedInstances4 { - implicit def nestedAlternative[F[_]: Alternative, G[_]: Applicative]: Alternative[Nested[F, G, ?]] = + implicit def catsDataAlternativeForNested[F[_]: Alternative, G[_]: Applicative]: Alternative[Nested[F, G, ?]] = new Alternative[Nested[F, G, ?]] { val instance = Alternative[F].compose[G] @@ -126,7 +126,7 @@ private[data] sealed abstract class NestedInstances3 extends NestedInstances4 { def empty[A]: Nested[F, G, A] = Nested(instance.empty[A]) } - implicit def nestedCovariantContravariant[F[_]: Functor, G[_]: Contravariant]: Contravariant[Nested[F, G, ?]] = + implicit def catsDataContravariantForContravariantNested[F[_]: Functor, G[_]: Contravariant]: Contravariant[Nested[F, G, ?]] = new Contravariant[Nested[F, G, ?]] { val instance = Functor[F].composeContravariant[G] @@ -136,7 +136,7 @@ private[data] sealed abstract class NestedInstances3 extends NestedInstances4 { } private[data] sealed abstract class NestedInstances4 extends NestedInstances5 { - implicit def nestedApplicative[F[_]: Applicative, G[_]: Applicative]: Applicative[Nested[F, G, ?]] = + implicit def catsDataApplicativeForNested[F[_]: Applicative, G[_]: Applicative]: Applicative[Nested[F, G, ?]] = new Applicative[Nested[F, G, ?]] { val instance = Applicative[F].compose[G] @@ -155,7 +155,7 @@ private[data] sealed abstract class NestedInstances4 extends NestedInstances5 { def pure[A](x: A): Nested[F, G, A] = Nested(instance.pure(x)) } - implicit def nestedMonoidK[F[_]: MonoidK, G[_]]: MonoidK[Nested[F, G, ?]] = + implicit def catsDataMonoidKForNested[F[_]: MonoidK, G[_]]: MonoidK[Nested[F, G, ?]] = new MonoidK[Nested[F, G, ?]] { val instance = MonoidK[F].compose[G] @@ -166,7 +166,7 @@ private[data] sealed abstract class NestedInstances4 extends NestedInstances5 { } private[data] sealed abstract class NestedInstances5 extends NestedInstances6 { - implicit def nestedApply[F[_]: Apply, G[_]: Apply]: Apply[Nested[F, G, ?]] = + implicit def catsDataApplyForNested[F[_]: Apply, G[_]: Apply]: Apply[Nested[F, G, ?]] = new Apply[Nested[F, G, ?]] { val instance = Apply[F].compose[G] @@ -180,7 +180,7 @@ private[data] sealed abstract class NestedInstances5 extends NestedInstances6 { Nested(instance.map(fga.value)(f)) } - implicit def nestedSemigroupK[F[_]: SemigroupK, G[_]]: SemigroupK[Nested[F, G, ?]] = + implicit def catsDataSemigroupKForNested[F[_]: SemigroupK, G[_]]: SemigroupK[Nested[F, G, ?]] = new SemigroupK[Nested[F, G, ?]] { val instance = SemigroupK[F].compose[G] @@ -189,7 +189,7 @@ private[data] sealed abstract class NestedInstances5 extends NestedInstances6 { } private[data] sealed abstract class NestedInstances6 extends NestedInstances7 { - implicit def nestedFunctor[F[_]: Functor, G[_]: Functor]: Functor[Nested[F, G, ?]] = + implicit def catsDataFunctorForNested[F[_]: Functor, G[_]: Functor]: Functor[Nested[F, G, ?]] = new Functor[Nested[F, G, ?]] { val instance = Functor[F].compose[G] @@ -202,7 +202,7 @@ private[data] sealed abstract class NestedInstances6 extends NestedInstances7 { } private[data] sealed abstract class NestedInstances7 extends NestedInstances8 { - implicit def nestedInvariant[F[_]: Invariant, G[_]: Invariant]: Invariant[Nested[F, G, ?]] = + implicit def catsDataInvariantForNested[F[_]: Invariant, G[_]: Invariant]: Invariant[Nested[F, G, ?]] = new Invariant[Nested[F, G, ?]] { val instance = Invariant[F].compose[G] @@ -212,7 +212,7 @@ private[data] sealed abstract class NestedInstances7 extends NestedInstances8 { } private[data] sealed abstract class NestedInstances8 extends NestedInstances9 { - implicit def nestedInvariantCovariant[F[_]: Invariant, G[_]: Functor]: Invariant[Nested[F, G, ?]] = + implicit def catsDataInvariantForCovariantNested[F[_]: Invariant, G[_]: Functor]: Invariant[Nested[F, G, ?]] = new Invariant[Nested[F, G, ?]] { val instance = Invariant[F].composeFunctor[G] @@ -222,7 +222,7 @@ private[data] sealed abstract class NestedInstances8 extends NestedInstances9 { } private[data] sealed abstract class NestedInstances9 { - implicit def nestedInvariantContravariant[F[_]: Invariant, G[_]: Contravariant]: Invariant[Nested[F, G, ?]] = + implicit def catsDataInvariantForNestedContravariant[F[_]: Invariant, G[_]: Contravariant]: Invariant[Nested[F, G, ?]] = new Invariant[Nested[F, G, ?]] { val instance = Invariant[F].composeContravariant[G] diff --git a/core/src/main/scala/cats/data/OneAnd.scala b/core/src/main/scala/cats/data/OneAnd.scala index 1541ceeaff..4c236ae572 100644 --- a/core/src/main/scala/cats/data/OneAnd.scala +++ b/core/src/main/scala/cats/data/OneAnd.scala @@ -138,7 +138,7 @@ private[data] sealed trait OneAndInstances extends OneAndLowPriority2 { } trait OneAndLowPriority0 { - implicit val nelComonad: Comonad[OneAnd[List, ?]] = + implicit val catsDataComonadForOneAnd: Comonad[OneAnd[List, ?]] = new Comonad[OneAnd[List, ?]] { def coflatMap[A, B](fa: OneAnd[List, A])(f: OneAnd[List, A] => B): OneAnd[List, B] = { @tailrec def consume(as: List[A], buf: ListBuffer[B]): List[B] = diff --git a/core/src/main/scala/cats/data/Validated.scala b/core/src/main/scala/cats/data/Validated.scala index 0d52616c4a..d8a1f2c44a 100644 --- a/core/src/main/scala/cats/data/Validated.scala +++ b/core/src/main/scala/cats/data/Validated.scala @@ -312,12 +312,12 @@ private[data] sealed abstract class ValidatedInstances extends ValidatedInstance private[data] sealed abstract class ValidatedInstances1 extends ValidatedInstances2 { - implicit def validatedSemigroup[A, B](implicit A: Semigroup[A], B: Semigroup[B]): Semigroup[Validated[A, B]] = + implicit def catsDataSemigroupForValidated[A, B](implicit A: Semigroup[A], B: Semigroup[B]): Semigroup[Validated[A, B]] = new Semigroup[Validated[A, B]] { def combine(x: Validated[A, B], y: Validated[A, B]): Validated[A, B] = x combine y } - implicit def validatedPartialOrder[A: PartialOrder, B: PartialOrder]: PartialOrder[Validated[A,B]] = + implicit def catsDataPartialOrderForValidated[A: PartialOrder, B: PartialOrder]: PartialOrder[Validated[A,B]] = new PartialOrder[Validated[A,B]] { def partialCompare(x: Validated[A,B], y: Validated[A,B]): Double = x partialCompare y override def eqv(x: Validated[A,B], y: Validated[A,B]): Boolean = x === y @@ -325,7 +325,7 @@ private[data] sealed abstract class ValidatedInstances1 extends ValidatedInstanc } private[data] sealed abstract class ValidatedInstances2 { - implicit def validatedEq[A: Eq, B: Eq]: Eq[Validated[A,B]] = + implicit def catsDataEqForValidated[A: Eq, B: Eq]: Eq[Validated[A,B]] = new Eq[Validated[A,B]] { def eqv(x: Validated[A,B], y: Validated[A,B]): Boolean = x === y } diff --git a/core/src/main/scala/cats/data/XorT.scala b/core/src/main/scala/cats/data/XorT.scala index be129f4b6b..8d8e819220 100644 --- a/core/src/main/scala/cats/data/XorT.scala +++ b/core/src/main/scala/cats/data/XorT.scala @@ -241,7 +241,7 @@ private[data] abstract class XorTInstances extends XorTInstances1 { val F0: Traverse[F] = F } - implicit def xortTransLift[E]: TransLift.Aux[XorT[?[_], E, ?], Functor] = + implicit def catsDataTransLiftForXorT[E]: TransLift.Aux[XorT[?[_], E, ?], Functor] = new TransLift[XorT[?[_], E, ?]] { type TC[M[_]] = Functor[M] diff --git a/core/src/main/scala/cats/functor/Invariant.scala b/core/src/main/scala/cats/functor/Invariant.scala index 5914d6d6f9..0ea0c719e0 100644 --- a/core/src/main/scala/cats/functor/Invariant.scala +++ b/core/src/main/scala/cats/functor/Invariant.scala @@ -36,14 +36,14 @@ object Invariant extends AlgebraInvariantInstances */ private[functor] sealed trait AlgebraInvariantInstances { - implicit val invariantSemigroup: Invariant[Semigroup] = new Invariant[Semigroup] { + implicit val catsFunctorInvariantForSemigroup: Invariant[Semigroup] = new Invariant[Semigroup] { def imap[A, B](fa: Semigroup[A])(f: A => B)(g: B => A): Semigroup[B] = new Semigroup[B] { def combine(x: B, y: B): B = f(fa.combine(g(x), g(y))) } } - implicit val invariantMonoid: Invariant[Monoid] = new Invariant[Monoid] { + implicit val catsFunctorInvariantForMonoid: Invariant[Monoid] = new Invariant[Monoid] { def imap[A, B](fa: Monoid[A])(f: A => B)(g: B => A): Monoid[B] = new Monoid[B] { val empty = f(fa.empty) diff --git a/core/src/main/scala/cats/package.scala b/core/src/main/scala/cats/package.scala index dc4b89373a..bc16a90951 100644 --- a/core/src/main/scala/cats/package.scala +++ b/core/src/main/scala/cats/package.scala @@ -29,7 +29,7 @@ package object cats { * encodes pure unary function application. */ type Id[A] = A - implicit val idInstances: Bimonad[Id] with MonadRec[Id] with Traverse[Id] = + implicit val catsInstancesForId: Bimonad[Id] with MonadRec[Id] with Traverse[Id] = new Bimonad[Id] with MonadRec[Id] with Traverse[Id] { def pure[A](a: A): A = a def extract[A](a: A): A = a diff --git a/free/src/main/scala/cats/free/Coyoneda.scala b/free/src/main/scala/cats/free/Coyoneda.scala index 2bf8ec5774..36625ca744 100644 --- a/free/src/main/scala/cats/free/Coyoneda.scala +++ b/free/src/main/scala/cats/free/Coyoneda.scala @@ -63,7 +63,7 @@ object Coyoneda { /** * As the free functor, `Coyoneda[F, ?]` provides a functor for any `F`. */ - implicit def coyonedaFunctor[F[_]]: Functor[Coyoneda[F, ?]] = + implicit def catsFreeFunctorForCoyoneda[F[_]]: Functor[Coyoneda[F, ?]] = new Functor[Coyoneda[F, ?]] { def map[A, B](cfa: Coyoneda[F, A])(f: A => B): Coyoneda[F, B] = cfa map f } diff --git a/free/src/main/scala/cats/free/Free.scala b/free/src/main/scala/cats/free/Free.scala index d5734b179d..c7c6c5cf4c 100644 --- a/free/src/main/scala/cats/free/Free.scala +++ b/free/src/main/scala/cats/free/Free.scala @@ -138,7 +138,7 @@ sealed abstract class Free[S[_], A] extends Product with Serializable { new FunctionK[S, Free[T, ?]] { def apply[B](fa: S[B]): Free[T, B] = Suspend(f(fa)) } - }(Free.freeMonad) + }(Free.catsFreeMonadRecForFree) override def toString(): String = "Free(...)" @@ -195,7 +195,7 @@ object Free { /** * `Free[S, ?]` has a monad for any type constructor `S[_]`. */ - implicit def freeMonad[S[_]]: MonadRec[Free[S, ?]] = + implicit def catsFreeMonadRecForFree[S[_]]: MonadRec[Free[S, ?]] = new MonadRec[Free[S, ?]] { def pure[A](a: A): Free[S, A] = Free.pure(a) override def map[A, B](fa: Free[S, A])(f: A => B): Free[S, B] = fa.map(f) diff --git a/free/src/main/scala/cats/free/Inject.scala b/free/src/main/scala/cats/free/Inject.scala index eb56f0f014..c1e54680a6 100644 --- a/free/src/main/scala/cats/free/Inject.scala +++ b/free/src/main/scala/cats/free/Inject.scala @@ -16,21 +16,21 @@ sealed abstract class Inject[F[_], G[_]] { } private[free] sealed abstract class InjectInstances { - implicit def reflexiveInjectInstance[F[_]]: Inject[F, F] = + implicit def catsFreeReflexiveInjectInstance[F[_]]: Inject[F, F] = new Inject[F, F] { def inj[A](fa: F[A]): F[A] = fa def prj[A](ga: F[A]): Option[F[A]] = Some(ga) } - implicit def leftInjectInstance[F[_], G[_]]: Inject[F, Coproduct[F, G, ?]] = + implicit def catsFreeLeftInjectInstance[F[_], G[_]]: Inject[F, Coproduct[F, G, ?]] = new Inject[F, Coproduct[F, G, ?]] { def inj[A](fa: F[A]): Coproduct[F, G, A] = Coproduct.leftc(fa) def prj[A](ga: Coproduct[F, G, A]): Option[F[A]] = ga.run.fold(Some(_), _ => None) } - implicit def rightInjectInstance[F[_], G[_], H[_]](implicit I: Inject[F, G]): Inject[F, Coproduct[H, G, ?]] = + implicit def catsFreeRightInjectInstance[F[_], G[_], H[_]](implicit I: Inject[F, G]): Inject[F, Coproduct[H, G, ?]] = new Inject[F, Coproduct[H, G, ?]] { def inj[A](fa: F[A]): Coproduct[H, G, A] = Coproduct.rightc(I.inj(fa)) diff --git a/free/src/main/scala/cats/free/Yoneda.scala b/free/src/main/scala/cats/free/Yoneda.scala index a7c14c0466..7f2b54438f 100644 --- a/free/src/main/scala/cats/free/Yoneda.scala +++ b/free/src/main/scala/cats/free/Yoneda.scala @@ -35,7 +35,7 @@ object Yoneda { /** * `Yoneda[F, _]` is a functor for any `F`. */ - implicit def yonedaFunctor[F[_]]: Functor[Yoneda[F, ?]] = + implicit def catsFreeFunctorForYoneda[F[_]]: Functor[Yoneda[F, ?]] = new Functor[Yoneda[F, ?]] { def map[A, B](ya: Yoneda[F, A])(f: A => B): Yoneda[F, B] = ya map f } diff --git a/free/src/test/scala/cats/free/FreeTests.scala b/free/src/test/scala/cats/free/FreeTests.scala index d0bdf9a64a..b2db47c362 100644 --- a/free/src/test/scala/cats/free/FreeTests.scala +++ b/free/src/test/scala/cats/free/FreeTests.scala @@ -5,7 +5,7 @@ import cats.tests.CatsSuite import cats.arrow.FunctionK import cats.data.Xor import cats.laws.discipline.{CartesianTests, MonadRecTests, SerializableTests} -import cats.laws.discipline.arbitrary.function0Arbitrary +import cats.laws.discipline.arbitrary.catsLawsArbitraryForFn0 import org.scalacheck.{Arbitrary, Gen} import Arbitrary.arbFunction1 diff --git a/kernel-laws/src/main/scala/cats/kernel/laws/package.scala b/kernel-laws/src/main/scala/cats/kernel/laws/package.scala index f4c7ed5ca0..f97de5ab1f 100644 --- a/kernel-laws/src/main/scala/cats/kernel/laws/package.scala +++ b/kernel-laws/src/main/scala/cats/kernel/laws/package.scala @@ -1,18 +1,11 @@ package cats.kernel -import org.typelevel.discipline.Predicate - import org.scalacheck._ import org.scalacheck.util.Pretty import Prop.{False, Proof, Result} package object laws { - implicit def nonEmptyPredicate[A](implicit ev: Eq[A], A: Monoid[A]): Predicate[A] = - new Predicate[A] { - def apply(a: A) = ev.neqv(a, A.empty) - } - lazy val proved = Prop(Result(status = Proof)) lazy val falsified = Prop(Result(status = False)) diff --git a/kernel/src/main/scala/cats/kernel/Eq.scala b/kernel/src/main/scala/cats/kernel/Eq.scala index 5ae4ec752e..4a25cbbab7 100644 --- a/kernel/src/main/scala/cats/kernel/Eq.scala +++ b/kernel/src/main/scala/cats/kernel/Eq.scala @@ -75,7 +75,7 @@ object Eq extends EqFunctions[Eq] { /** * This gives compatibility with scala's Equiv trait */ - implicit def equiv[A](implicit ev: Eq[A]): Equiv[A] = + implicit def catsKernelEquivForEq[A](implicit ev: Eq[A]): Equiv[A] = new Equiv[A] { def equiv(a: A, b: A) = ev.eqv(a, b) } diff --git a/kernel/src/main/scala/cats/kernel/Order.scala b/kernel/src/main/scala/cats/kernel/Order.scala index 577214057e..32f29f1634 100644 --- a/kernel/src/main/scala/cats/kernel/Order.scala +++ b/kernel/src/main/scala/cats/kernel/Order.scala @@ -164,7 +164,7 @@ object Order extends OrderFunctions[Order] { * Implicitly convert a `Order[A]` to a `scala.math.Ordering[A]` * instance. */ - implicit def ordering[A](implicit ev: Order[A]): Ordering[A] = + implicit def catsKernelOrderingForOrder[A](implicit ev: Order[A]): Ordering[A] = ev.toOrdering /** diff --git a/kernel/src/main/scala/cats/kernel/PartialOrder.scala b/kernel/src/main/scala/cats/kernel/PartialOrder.scala index 9d5f35ecb6..7a56eeabf8 100644 --- a/kernel/src/main/scala/cats/kernel/PartialOrder.scala +++ b/kernel/src/main/scala/cats/kernel/PartialOrder.scala @@ -167,7 +167,7 @@ object PartialOrder extends PartialOrderFunctions[PartialOrder] { * Implicitly convert a `PartialOrder[A]` to a * `scala.math.PartialOrdering[A]` instance. */ - implicit def partialOrdering[A](implicit ev: PartialOrder[A]): PartialOrdering[A] = + implicit def catsKernelPartialOrderingForPartialOrder[A](implicit ev: PartialOrder[A]): PartialOrdering[A] = new PartialOrdering[A] { def tryCompare(x: A, y: A): Option[Int] = ev.tryCompare(x, y) def lteq(x: A, y: A): Boolean = ev.lteqv(x, y) diff --git a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala index 7e823c6a06..41efdee091 100644 --- a/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala +++ b/laws/src/main/scala/cats/laws/discipline/Arbitrary.scala @@ -14,77 +14,77 @@ object arbitrary extends ArbitraryInstances0 { // A special function1Arbitrary for testing operations like dropWhile specifically // in the context of Int => Boolean. Once scalacheck supports better Function1 arbitrary // instances this can be removed. - implicit def function1Arbitrary: Arbitrary[(Int) => Boolean] = + implicit def catsLawsArbitraryForIntToBool: Arbitrary[(Int) => Boolean] = Arbitrary(getArbitrary[Int].map(x => (input) => input < x)) - implicit def constArbitrary[A, B](implicit A: Arbitrary[A]): Arbitrary[Const[A, B]] = + implicit def catsLawsArbitraryForConst[A, B](implicit A: Arbitrary[A]): Arbitrary[Const[A, B]] = Arbitrary(A.arbitrary.map(Const[A, B])) - implicit def oneAndArbitrary[F[_], A](implicit A: Arbitrary[A], F: Arbitrary[F[A]]): Arbitrary[OneAnd[F, A]] = + implicit def catsLawsArbitraryForOneAnd[F[_], A](implicit A: Arbitrary[A], F: Arbitrary[F[A]]): Arbitrary[OneAnd[F, A]] = Arbitrary(F.arbitrary.flatMap(fa => A.arbitrary.map(a => OneAnd(a, fa)))) - implicit def xorArbitrary[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[A Xor B] = + implicit def catsLawsArbitraryForXor[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[A Xor B] = Arbitrary(Gen.oneOf(A.arbitrary.map(Xor.left), B.arbitrary.map(Xor.right))) - implicit def xorTArbitrary[F[_], A, B](implicit F: Arbitrary[F[A Xor B]]): Arbitrary[XorT[F, A, B]] = + implicit def catsLawsArbitraryForXorT[F[_], A, B](implicit F: Arbitrary[F[A Xor B]]): Arbitrary[XorT[F, A, B]] = Arbitrary(F.arbitrary.map(XorT(_))) - implicit def validatedArbitrary[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[Validated[A, B]] = + implicit def catsLawsArbitraryForValidated[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[Validated[A, B]] = Arbitrary(Gen.oneOf(A.arbitrary.map(Validated.invalid), B.arbitrary.map(Validated.valid))) - implicit def iorArbitrary[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[A Ior B] = + implicit def catsLawsArbitraryForIor[A, B](implicit A: Arbitrary[A], B: Arbitrary[B]): Arbitrary[A Ior B] = Arbitrary(Gen.oneOf(A.arbitrary.map(Ior.left), B.arbitrary.map(Ior.right), for { a <- A.arbitrary; b <- B.arbitrary } yield Ior.both(a, b))) - implicit def kleisliArbitrary[F[_], A, B](implicit F: Arbitrary[F[B]]): Arbitrary[Kleisli[F, A, B]] = + implicit def catsLawsArbitraryForKleisli[F[_], A, B](implicit F: Arbitrary[F[B]]): Arbitrary[Kleisli[F, A, B]] = Arbitrary(F.arbitrary.map(fb => Kleisli[F, A, B](_ => fb))) - implicit def cokleisliArbitrary[F[_], A, B](implicit B: Arbitrary[B]): Arbitrary[Cokleisli[F, A, B]] = + implicit def catsLawsArbitraryForCokleisli[F[_], A, B](implicit B: Arbitrary[B]): Arbitrary[Cokleisli[F, A, B]] = Arbitrary(B.arbitrary.map(b => Cokleisli[F, A, B](_ => b))) - implicit def optionTArbitrary[F[_], A](implicit F: Arbitrary[F[Option[A]]]): Arbitrary[OptionT[F, A]] = + implicit def catsLawsArbitraryForOptionT[F[_], A](implicit F: Arbitrary[F[Option[A]]]): Arbitrary[OptionT[F, A]] = Arbitrary(F.arbitrary.map(OptionT.apply)) - implicit def idTArbitrary[F[_], A](implicit F: Arbitrary[F[A]]): Arbitrary[IdT[F, A]] = + implicit def catsLawsArbitraryForIdT[F[_], A](implicit F: Arbitrary[F[A]]): Arbitrary[IdT[F, A]] = Arbitrary(F.arbitrary.map(IdT.apply)) - implicit def evalArbitrary[A: Arbitrary]: Arbitrary[Eval[A]] = + implicit def catsLawsArbitraryForEval[A: Arbitrary]: Arbitrary[Eval[A]] = Arbitrary(Gen.oneOf( getArbitrary[A].map(Eval.now(_)), getArbitrary[A].map(Eval.later(_)), getArbitrary[A].map(Eval.always(_)))) - implicit def prodArbitrary[F[_], G[_], A](implicit F: Arbitrary[F[A]], G: Arbitrary[G[A]]): Arbitrary[Prod[F, G, A]] = + implicit def catsLawsArbitraryForProd[F[_], G[_], A](implicit F: Arbitrary[F[A]], G: Arbitrary[G[A]]): Arbitrary[Prod[F, G, A]] = Arbitrary(F.arbitrary.flatMap(fa => G.arbitrary.map(ga => Prod[F, G, A](fa, ga)))) - implicit def funcArbitrary[F[_], A, B](implicit F: Arbitrary[F[B]]): Arbitrary[Func[F, A, B]] = + implicit def catsLawsArbitraryForFunc[F[_], A, B](implicit F: Arbitrary[F[B]]): Arbitrary[Func[F, A, B]] = Arbitrary(F.arbitrary.map(fb => Func.func[F, A, B](_ => fb))) - implicit def appFuncArbitrary[F[_], A, B](implicit F: Arbitrary[F[B]], FF: Applicative[F]): Arbitrary[AppFunc[F, A, B]] = + implicit def catsLawsArbitraryForAppFunc[F[_], A, B](implicit F: Arbitrary[F[B]], FF: Applicative[F]): Arbitrary[AppFunc[F, A, B]] = Arbitrary(F.arbitrary.map(fb => Func.appFunc[F, A, B](_ => fb))) - implicit def writerArbitrary[L:Arbitrary, V:Arbitrary]: Arbitrary[Writer[L, V]] = - writerTArbitrary[Id, L, V] + implicit def catsLawsArbitraryForWriter[L:Arbitrary, V:Arbitrary]: Arbitrary[Writer[L, V]] = + catsLawsArbitraryForWriterT[Id, L, V] // until this is provided by scalacheck - implicit def partialFunctionArbitrary[A, B](implicit F: Arbitrary[A => Option[B]]): Arbitrary[PartialFunction[A, B]] = + implicit def catsLawsArbitraryForPartialFunction[A, B](implicit F: Arbitrary[A => Option[B]]): Arbitrary[PartialFunction[A, B]] = Arbitrary(F.arbitrary.map(Function.unlift)) - implicit def coproductArbitrary[F[_], G[_], A](implicit F: Arbitrary[F[A]], G: Arbitrary[G[A]]): Arbitrary[Coproduct[F, G, A]] = + implicit def catsLawsArbitraryForCoproduct[F[_], G[_], A](implicit F: Arbitrary[F[A]], G: Arbitrary[G[A]]): Arbitrary[Coproduct[F, G, A]] = Arbitrary(Gen.oneOf( F.arbitrary.map(Coproduct.leftc[F, G, A]), G.arbitrary.map(Coproduct.rightc[F, G, A]))) - implicit def showArbitrary[A: Arbitrary]: Arbitrary[Show[A]] = + implicit def catsLawsArbitraryForShow[A: Arbitrary]: Arbitrary[Show[A]] = Arbitrary(Show.fromToString[A]) - implicit def function0Arbitrary[A: Arbitrary]: Arbitrary[() => A] = + implicit def catsLawsArbitraryForFn0[A: Arbitrary]: Arbitrary[() => A] = Arbitrary(getArbitrary[A].map(() => _)) - implicit def nestedArbitrary[F[_], G[_], A](implicit FG: Arbitrary[F[G[A]]]): Arbitrary[Nested[F, G, A]] = + implicit def catsLawsArbitraryForNested[F[_], G[_], A](implicit FG: Arbitrary[F[G[A]]]): Arbitrary[Nested[F, G, A]] = Arbitrary(FG.arbitrary.map(Nested(_))) } private[discipline] sealed trait ArbitraryInstances0 { - implicit def writerTArbitrary[F[_], L, V](implicit F: Arbitrary[F[(L, V)]]): Arbitrary[WriterT[F, L, V]] = + implicit def catsLawsArbitraryForWriterT[F[_], L, V](implicit F: Arbitrary[F[(L, V)]]): Arbitrary[WriterT[F, L, V]] = Arbitrary(F.arbitrary.map(WriterT(_))) } diff --git a/laws/src/main/scala/cats/laws/discipline/Eq.scala b/laws/src/main/scala/cats/laws/discipline/Eq.scala index 432b1d7a80..406b95f56f 100644 --- a/laws/src/main/scala/cats/laws/discipline/Eq.scala +++ b/laws/src/main/scala/cats/laws/discipline/Eq.scala @@ -12,7 +12,7 @@ object eq { * Create an approximation of Eq[A => B] by generating 100 values for A * and comparing the application of the two functions. */ - implicit def function1Eq[A, B](implicit A: Arbitrary[A], B: Eq[B]): Eq[A => B] = new Eq[A => B] { + implicit def catsLawsEqForFn1[A, B](implicit A: Arbitrary[A], B: Eq[B]): Eq[A => B] = new Eq[A => B] { val sampleCnt: Int = if (Platform.isJvm) 50 else 5 def eqv(f: A => B, g: A => B): Boolean = { @@ -24,9 +24,9 @@ object eq { } } - /** Create an approximation of Eq[Show[A]] by using function1Eq[A, String] */ - implicit def showEq[A: Arbitrary]: Eq[Show[A]] = { - val xyz = function1Eq[A, String] + /** Create an approximation of Eq[Show[A]] by using catsLawsEqForFn1[A, String] */ + implicit def catsLawsEqForShow[A: Arbitrary]: Eq[Show[A]] = { + val xyz = catsLawsEqForFn1[A, String] Eq.by[Show[A], A => String] { showInstance => (a: A) => showInstance.show(a) } @@ -36,18 +36,14 @@ object eq { * Create an approximation of Eq[Semigroup[A]] by generating values for A * and comparing the application of the two combine functions. */ - implicit def semigroupEq[A](implicit arbAA: Arbitrary[(A, A)], eqA: Eq[A]): Eq[Semigroup[A]] = - function1Eq[(A, A), A].on(f => + implicit def catsLawsEqForSemigroup[A](implicit arbAA: Arbitrary[(A, A)], eqA: Eq[A]): Eq[Semigroup[A]] = + catsLawsEqForFn1[(A, A), A].on(f => Function.tupled((x, y) => f.combine(x, y)) ) - implicit def monoidEq[A](implicit eqSA: Eq[Semigroup[A]], eqA: Eq[A]): Eq[Monoid[A]] = new Eq[Monoid[A]] { + implicit def catsLawsEqForMonoid[A](implicit eqSA: Eq[Semigroup[A]], eqA: Eq[A]): Eq[Monoid[A]] = new Eq[Monoid[A]] { def eqv(f: Monoid[A], g: Monoid[A]): Boolean = { eqSA.eqv(f, g) && eqA.eqv(f.empty, g.empty) } } - - implicit val unitEq: Eq[Unit] = new Eq[Unit] { - def eqv(a: Unit, b: Unit): Boolean = true - } } diff --git a/laws/src/main/scala/cats/laws/discipline/package.scala b/laws/src/main/scala/cats/laws/discipline/package.scala index 6862b3036c..b4fb5ca831 100644 --- a/laws/src/main/scala/cats/laws/discipline/package.scala +++ b/laws/src/main/scala/cats/laws/discipline/package.scala @@ -6,6 +6,6 @@ import cats.kernel.laws._ import org.scalacheck.Prop package object discipline { - implicit def isEqToProp[A: Eq](isEq: IsEq[A]): Prop = + implicit def catsLawsIsEqToProp[A: Eq](isEq: IsEq[A]): Prop = isEq.lhs ?== isEq.rhs } diff --git a/tests/src/test/scala/cats/tests/CategoryTests.scala b/tests/src/test/scala/cats/tests/CategoryTests.scala index dc0de32190..a052e7c9fe 100644 --- a/tests/src/test/scala/cats/tests/CategoryTests.scala +++ b/tests/src/test/scala/cats/tests/CategoryTests.scala @@ -5,7 +5,7 @@ import cats.kernel.laws.GroupLaws import cats.arrow.Category import cats.laws.discipline.{MonoidKTests, SerializableTests} -import cats.laws.discipline.eq.function1Eq +import cats.laws.discipline.eq.catsLawsEqForFn1 class CategoryTest extends CatsSuite { val functionCategory = Category[Function1] diff --git a/tests/src/test/scala/cats/tests/CokleisliTests.scala b/tests/src/test/scala/cats/tests/CokleisliTests.scala index 212de1f56b..342f33a108 100644 --- a/tests/src/test/scala/cats/tests/CokleisliTests.scala +++ b/tests/src/test/scala/cats/tests/CokleisliTests.scala @@ -37,10 +37,10 @@ class CokleisliTests extends SlowCatsSuite { type CokleisliNEL[A, B] = Cokleisli[NonEmptyList, A, B] implicit def ev0[A: Arbitrary, B: Arbitrary]: Arbitrary[CokleisliNEL[A, B]] = - cokleisliArbitrary + catsLawsArbitraryForCokleisli implicit def ev1[A: Arbitrary, B: Eq]: Eq[CokleisliNEL[A, B]] = - cokleisliEq[NonEmptyList, A, B](oneAndArbitrary, Eq[B]) + cokleisliEq[NonEmptyList, A, B](catsLawsArbitraryForOneAnd, Eq[B]) checkAll("Cokleisli[NonEmptyList, Int, Int]", ArrowTests[CokleisliNEL].arrow[Int, Int, Int, Int, Int, Int]) checkAll("Arrow[Cokleisli[NonEmptyList, ?, ?]]", SerializableTests.serializable(Arrow[CokleisliNEL])) @@ -51,10 +51,10 @@ class CokleisliTests extends SlowCatsSuite { type CokleisliNELE[A] = Cokleisli[NonEmptyList, A, A] implicit def ev0[A: Arbitrary]: Arbitrary[CokleisliNELE[A]] = - cokleisliArbitrary[NonEmptyList, A, A] + catsLawsArbitraryForCokleisli[NonEmptyList, A, A] implicit def ev1[A: Eq](implicit arb: Arbitrary[A]): Eq[CokleisliNELE[A]] = - cokleisliEqE[NonEmptyList, A](oneAndArbitrary, Eq[A]) + cokleisliEqE[NonEmptyList, A](catsLawsArbitraryForOneAnd, Eq[A]) { implicit val cokleisliMonoidK = Cokleisli.catsDataMonoidKForCokleisli[NonEmptyList] diff --git a/tests/src/test/scala/cats/tests/ComposeTest.scala b/tests/src/test/scala/cats/tests/ComposeTest.scala index d6694e7caf..55c3df6bc4 100644 --- a/tests/src/test/scala/cats/tests/ComposeTest.scala +++ b/tests/src/test/scala/cats/tests/ComposeTest.scala @@ -5,7 +5,7 @@ import cats.kernel.laws.GroupLaws import cats.arrow.Compose import cats.laws.discipline.{SemigroupKTests, SerializableTests} -import cats.laws.discipline.eq.function1Eq +import cats.laws.discipline.eq.catsLawsEqForFn1 class ComposeTest extends CatsSuite { val functionCompose = Compose[Function1] diff --git a/tests/src/test/scala/cats/tests/ConstTests.scala b/tests/src/test/scala/cats/tests/ConstTests.scala index fafce196bc..ae0f0c0017 100644 --- a/tests/src/test/scala/cats/tests/ConstTests.scala +++ b/tests/src/test/scala/cats/tests/ConstTests.scala @@ -6,7 +6,7 @@ import cats.kernel.laws.{GroupLaws, OrderLaws} import cats.data.{Const, NonEmptyList} import cats.functor.Contravariant import cats.laws.discipline._ -import cats.laws.discipline.arbitrary.{constArbitrary, oneAndArbitrary} +import cats.laws.discipline.arbitrary.{catsLawsArbitraryForConst, catsLawsArbitraryForOneAnd} class ConstTests extends CatsSuite { diff --git a/tests/src/test/scala/cats/tests/MonadCombineTests.scala b/tests/src/test/scala/cats/tests/MonadCombineTests.scala index 32b3577d77..6a4901b10a 100644 --- a/tests/src/test/scala/cats/tests/MonadCombineTests.scala +++ b/tests/src/test/scala/cats/tests/MonadCombineTests.scala @@ -2,7 +2,7 @@ package cats package tests import cats.data.Xor -import cats.laws.discipline.arbitrary.xorArbitrary +import cats.laws.discipline.arbitrary.catsLawsArbitraryForXor class MonadCombineTest extends CatsSuite { test("separate") { diff --git a/tests/src/test/scala/cats/tests/NestedTests.scala b/tests/src/test/scala/cats/tests/NestedTests.scala index 7625b70d86..d2318b0860 100644 --- a/tests/src/test/scala/cats/tests/NestedTests.scala +++ b/tests/src/test/scala/cats/tests/NestedTests.scala @@ -6,7 +6,7 @@ import cats.functor._ import cats.laws.discipline._ import cats.laws.discipline.CartesianTests.Isomorphisms._ import cats.laws.discipline.arbitrary._ -import cats.laws.discipline.eq.showEq +import cats.laws.discipline.eq.catsLawsEqForShow class NestedTests extends CatsSuite { // we have a lot of generated lists of lists in these tests. We have to tell @@ -29,14 +29,14 @@ class NestedTests extends CatsSuite { { // Invariant + Covariant = Invariant - val instance = Nested.nestedInvariantCovariant(ListWrapper.invariant, ListWrapper.functor) + val instance = Nested.catsDataInvariantForCovariantNested(ListWrapper.invariant, ListWrapper.functor) checkAll("Nested[ListWrapper, ListWrapper] - Invariant + Covariant", InvariantTests[Nested[ListWrapper, ListWrapper, ?]](instance).invariant[Int, Int, Int]) checkAll("Invariant[Nested[ListWrapper, ListWrapper, ?]] - Invariant + Covariant", SerializableTests.serializable(instance)) } { // Invariant + Contravariant = Invariant - val instance = Nested.nestedInvariantContravariant(ListWrapper.invariant, Contravariant[Show]) + val instance = Nested.catsDataInvariantForNestedContravariant(ListWrapper.invariant, Contravariant[Show]) checkAll("Nested[ListWrapper, Show]", InvariantTests[Nested[ListWrapper, Show, ?]](instance).invariant[Int, Int, Int]) checkAll("Invariant[Nested[ListWrapper, Show, ?]]", SerializableTests.serializable(instance)) } @@ -58,9 +58,9 @@ class NestedTests extends CatsSuite { // Contravariant + Contravariant = Functor type ConstInt[A] = Const[Int, A] // SI-2712 - implicit val instance = Nested.nestedContravariant[ConstInt, Show] - implicit val arbitrary = nestedArbitrary[ConstInt, Show, Int] - implicit val eqv = Nested.nestedEq[ConstInt, Show, Int] + implicit val instance = Nested.catsDataContravariantForNested[ConstInt, Show] + implicit val arbitrary = catsLawsArbitraryForNested[ConstInt, Show, Int] + implicit val eqv = Nested.catsDataEqForNested[ConstInt, Show, Int] checkAll("Nested[Const[Int, ?], Show, ?]", FunctorTests[Nested[ConstInt, Show, ?]].functor[Int, Int, Int]) checkAll("Functor[Nested[Const[Int, ?], Show, ?]]", SerializableTests.serializable(instance)) } @@ -96,9 +96,9 @@ class NestedTests extends CatsSuite { // SI-2712? It can resolve Reducible[NonEmptyList] and Reducible[NonEmptyVector] but not // Reducible[Nested[NonEmptyList, NonEmptyVector, ?]] // Similarly for Arbitrary. - implicit val reducible = Nested.nestedReducible[NonEmptyList, NonEmptyVector] - implicit val arbitrary0 = nestedArbitrary[NonEmptyList, NonEmptyVector, Int] - implicit val arbitrary1 = nestedArbitrary[NonEmptyList, NonEmptyVector, Option[Int]] + implicit val reducible = Nested.catsDataReducibleForNested[NonEmptyList, NonEmptyVector] + implicit val arbitrary0 = catsLawsArbitraryForNested[NonEmptyList, NonEmptyVector, Int] + implicit val arbitrary1 = catsLawsArbitraryForNested[NonEmptyList, NonEmptyVector, Option[Int]] checkAll("Nested[NonEmptyList, NonEmptyVector, ?]", ReducibleTests[Nested[NonEmptyList, NonEmptyVector, ?]].reducible[Option, Int, Int]) checkAll("Reducible[Nested[NonEmptyList, NonEmptyVector, ?]]", SerializableTests.serializable(reducible))