diff --git a/CHANGES.md b/CHANGES.md index eeacac628e..0308709f83 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -723,9 +723,9 @@ previously been provided by `Apply`, you'll need to change your imports from `cats.syntax.apply._` to `cats.syntax.cartesian._`. For example: ```scala -scala> import cats.Eval, cats.syntax.cartesian._ +scala> import cats.Eval, cats.syntax.semigroupal._ import cats.Eval -import cats.syntax.cartesian._ +import cats.syntax.semigroupal._ scala> (Eval.now("v") |@| Eval.now(0.4)).tupled res0: cats.Eval[(String, Double)] = cats.Eval$$anon$5@104f8bbd diff --git a/core/src/main/scala/cats/Apply.scala b/core/src/main/scala/cats/Apply.scala index 0d28130263..a91a1086f4 100644 --- a/core/src/main/scala/cats/Apply.scala +++ b/core/src/main/scala/cats/Apply.scala @@ -8,7 +8,7 @@ import simulacrum.typeclass * Must obey the laws defined in cats.laws.ApplyLaws. */ @typeclass(excludeParents = List("ApplyArityFunctions")) -trait Apply[F[_]] extends Functor[F] with Cartesian[F] with ApplyArityFunctions[F] { self => +trait Apply[F[_]] extends Functor[F] with Semigroupal[F] with ApplyArityFunctions[F] { self => /** * Given a value and a function in the Apply context, applies the diff --git a/core/src/main/scala/cats/Composed.scala b/core/src/main/scala/cats/Composed.scala index 8f85c5995f..6ed0c8a19d 100644 --- a/core/src/main/scala/cats/Composed.scala +++ b/core/src/main/scala/cats/Composed.scala @@ -113,8 +113,8 @@ private[cats] trait ComposedContravariantCovariant[F[_], G[_]] extends Contravar F.contramap(fga)(gb => G.map(gb)(f)) } -private[cats] trait ComposedCartesian[F[_], G[_]] extends ContravariantCartesian[λ[α => F[G[α]]]] with ComposedContravariantCovariant[F, G] { outer => - def F: ContravariantCartesian[F] +private[cats] trait ComposedSemigroupal[F[_], G[_]] extends ContravariantSemigroupal[λ[α => F[G[α]]]] with ComposedContravariantCovariant[F, G] { outer => + def F: ContravariantSemigroupal[F] def G: Functor[G] def product[A, B](fa: F[G[A]], fb: F[G[B]]): F[G[(A, B)]] = diff --git a/core/src/main/scala/cats/ContravariantCartesian.scala b/core/src/main/scala/cats/ContravariantCartesian.scala index c3113d8a44..e90d2d14ac 100644 --- a/core/src/main/scala/cats/ContravariantCartesian.scala +++ b/core/src/main/scala/cats/ContravariantCartesian.scala @@ -3,12 +3,12 @@ package cats import simulacrum.typeclass /** - * [[ContravariantCartesian]] is nothing more than something both contravariant - * and Cartesian. It comes up enough to be useful, and composes well + * [[ContravariantSemigroupal]] is nothing more than something both contravariant + * and Semigroupal. It comes up enough to be useful, and composes well */ -@typeclass trait ContravariantCartesian[F[_]] extends Cartesian[F] with Contravariant[F] { self => - override def composeFunctor[G[_]: Functor]: ContravariantCartesian[λ[α => F[G[α]]]] = - new ComposedCartesian[F, G] { +@typeclass trait ContravariantSemigroupal[F[_]] extends Semigroupal[F] with Contravariant[F] { self => + override def composeFunctor[G[_]: Functor]: ContravariantSemigroupal[λ[α => F[G[α]]]] = + new ComposedSemigroupal[F, G] { def F = self def G = Functor[G] } diff --git a/core/src/main/scala/cats/InvariantMonoidal.scala b/core/src/main/scala/cats/InvariantMonoidal.scala index edf03663a5..37c3ada5de 100644 --- a/core/src/main/scala/cats/InvariantMonoidal.scala +++ b/core/src/main/scala/cats/InvariantMonoidal.scala @@ -7,6 +7,6 @@ import simulacrum.typeclass * * Must obey the laws defined in cats.laws.InvariantMonoidalLaws. */ -@typeclass trait InvariantMonoidal[F[_]] extends Invariant[F] with Cartesian[F] { +@typeclass trait InvariantMonoidal[F[_]] extends Invariant[F] with Semigroupal[F] { def pure[A](a: A): F[A] } diff --git a/core/src/main/scala/cats/Cartesian.scala b/core/src/main/scala/cats/Semigroupal.scala similarity index 68% rename from core/src/main/scala/cats/Cartesian.scala rename to core/src/main/scala/cats/Semigroupal.scala index a3543d009a..6fed1ca0e9 100644 --- a/core/src/main/scala/cats/Cartesian.scala +++ b/core/src/main/scala/cats/Semigroupal.scala @@ -3,17 +3,17 @@ package cats import simulacrum.typeclass /** - * [[Cartesian]] captures the idea of composing independent effectful values. + * [[Semigroupal]] captures the idea of composing independent effectful values. * It is of particular interest when taken together with [[Functor]] - where [[Functor]] * captures the idea of applying a unary pure function to an effectful value, * calling `product` with `map` allows one to apply a function of arbitrary arity to multiple * independent effectful values. * * That same idea is also manifested in the form of [[Apply]], and indeed [[Apply]] extends both - * [[Cartesian]] and [[Functor]] to illustrate this. + * [[Semigroupal]] and [[Functor]] to illustrate this. */ -@typeclass trait Cartesian[F[_]] { +@typeclass trait Semigroupal[F[_]] { def product[A, B](fa: F[A], fb: F[B]): F[(A, B)] } -object Cartesian extends CartesianArityFunctions +object Semigroupal extends SemigroupalArityFunctions diff --git a/core/src/main/scala/cats/instances/eq.scala b/core/src/main/scala/cats/instances/eq.scala index 6daf449e56..25ad3b3682 100644 --- a/core/src/main/scala/cats/instances/eq.scala +++ b/core/src/main/scala/cats/instances/eq.scala @@ -2,8 +2,8 @@ package cats package instances trait EqInstances { - implicit val catsContravariantCartesianForEq: ContravariantCartesian[Eq] = - new ContravariantCartesian[Eq] { + implicit val catsContravariantSemigroupalForEq: ContravariantSemigroupal[Eq] = + new ContravariantSemigroupal[Eq] { def contramap[A, B](fa: Eq[A])(fn: B => A): Eq[B] = fa.on(fn) def product[A, B](fa: Eq[A], fb: Eq[B]): Eq[(A, B)] = diff --git a/core/src/main/scala/cats/instances/equiv.scala b/core/src/main/scala/cats/instances/equiv.scala index f3ef2bc1e0..736fdaa12e 100644 --- a/core/src/main/scala/cats/instances/equiv.scala +++ b/core/src/main/scala/cats/instances/equiv.scala @@ -2,8 +2,8 @@ package cats package instances trait EquivInstances { - implicit val catsContravariantCartesianEquiv: ContravariantCartesian[Equiv] = - new ContravariantCartesian[Equiv] { + implicit val catsContravariantSemigroupalEquiv: ContravariantSemigroupal[Equiv] = + new ContravariantSemigroupal[Equiv] { def contramap[A, B](fa: Equiv[A])(f: B => A): Equiv[B] = new Equiv[B] { def equiv(x: B, y: B): Boolean = fa.equiv(f(x), f(y)) diff --git a/core/src/main/scala/cats/instances/order.scala b/core/src/main/scala/cats/instances/order.scala index 29fad0826d..4dfeafaad4 100644 --- a/core/src/main/scala/cats/instances/order.scala +++ b/core/src/main/scala/cats/instances/order.scala @@ -3,8 +3,8 @@ package instances trait OrderInstances extends cats.kernel.OrderToOrderingConversion { - implicit val catsContravariantCartesianForOrder: ContravariantCartesian[Order] = - new ContravariantCartesian[Order] { + implicit val catsContravariantSemigroupalForOrder: ContravariantSemigroupal[Order] = + new ContravariantSemigroupal[Order] { /** Derive an `Order` for `B` given an `Order[A]` and a function `B => A`. * * Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping) diff --git a/core/src/main/scala/cats/instances/ordering.scala b/core/src/main/scala/cats/instances/ordering.scala index cb8ea6e5a1..13240b7cbf 100644 --- a/core/src/main/scala/cats/instances/ordering.scala +++ b/core/src/main/scala/cats/instances/ordering.scala @@ -3,8 +3,8 @@ package instances trait OrderingInstances { - implicit val catsContravariantCartesianForOrdering: ContravariantCartesian[Ordering] = - new ContravariantCartesian[Ordering] { + implicit val catsContravariantSemigroupalForOrdering: ContravariantSemigroupal[Ordering] = + new ContravariantSemigroupal[Ordering] { /** Derive an `Ordering` for `B` given an `Ordering[A]` and a function `B => A`. * * Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping) diff --git a/core/src/main/scala/cats/instances/partialOrder.scala b/core/src/main/scala/cats/instances/partialOrder.scala index a8b4654e2e..9ab4c6b75f 100644 --- a/core/src/main/scala/cats/instances/partialOrder.scala +++ b/core/src/main/scala/cats/instances/partialOrder.scala @@ -2,8 +2,8 @@ package cats package instances trait PartialOrderInstances { - implicit val catsContravariantCartesianForPartialOrder: ContravariantCartesian[PartialOrder] = - new ContravariantCartesian[PartialOrder] { + implicit val catsContravariantSemigroupalForPartialOrder: ContravariantSemigroupal[PartialOrder] = + new ContravariantSemigroupal[PartialOrder] { /** Derive a `PartialOrder` for `B` given a `PartialOrder[A]` and a function `B => A`. * * Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping) diff --git a/core/src/main/scala/cats/instances/partialOrdering.scala b/core/src/main/scala/cats/instances/partialOrdering.scala index 5b02dc384a..d44d33e185 100644 --- a/core/src/main/scala/cats/instances/partialOrdering.scala +++ b/core/src/main/scala/cats/instances/partialOrdering.scala @@ -2,8 +2,8 @@ package cats package instances trait PartialOrderingInstances { - implicit val catsContravariantCartesianForPartialOrdering: ContravariantCartesian[PartialOrdering] = - new ContravariantCartesian[PartialOrdering] { + implicit val catsContravariantSemigroupalForPartialOrdering: ContravariantSemigroupal[PartialOrdering] = + new ContravariantSemigroupal[PartialOrdering] { /** Derive a `PartialOrdering` for `B` given a `PartialOrdering[A]` and a function `B => A`. * * Note: resulting instances are law-abiding only when the functions used are injective (represent a one-to-one mapping) diff --git a/core/src/main/scala/cats/package.scala b/core/src/main/scala/cats/package.scala index af9731e5d3..f4a862a021 100644 --- a/core/src/main/scala/cats/package.scala +++ b/core/src/main/scala/cats/package.scala @@ -90,4 +90,7 @@ package object cats { val Semigroup = cats.kernel.Semigroup val Monoid = cats.kernel.Monoid val Group = cats.kernel.Group + + @deprecated("renamed to Semigroupal", "1.0.0-RC1") + type Cartesian[F[_]] = Semigroupal[F] } diff --git a/core/src/main/scala/cats/syntax/all.scala b/core/src/main/scala/cats/syntax/all.scala index 04d099c21e..a214de15b5 100644 --- a/core/src/main/scala/cats/syntax/all.scala +++ b/core/src/main/scala/cats/syntax/all.scala @@ -10,7 +10,7 @@ trait AllSyntax with BifunctorSyntax with BifoldableSyntax with BitraverseSyntax - with CartesianSyntax + with SemigroupalSyntax with CoflatMapSyntax with ComonadSyntax with ComposeSyntax diff --git a/core/src/main/scala/cats/syntax/apply.scala b/core/src/main/scala/cats/syntax/apply.scala index bb0e736ab8..244766a310 100644 --- a/core/src/main/scala/cats/syntax/apply.scala +++ b/core/src/main/scala/cats/syntax/apply.scala @@ -1,7 +1,7 @@ package cats package syntax -trait ApplySyntax extends TupleCartesianSyntax { +trait ApplySyntax extends TupleSemigroupalSyntax { implicit final def catsSyntaxApply[F[_], A](fa: F[A])(implicit F: Apply[F]): Apply.Ops[F, A] = new Apply.Ops[F, A] { type TypeClassType = Apply[F] diff --git a/core/src/main/scala/cats/syntax/cartesian.scala b/core/src/main/scala/cats/syntax/cartesian.scala deleted file mode 100644 index cd2a13b1dc..0000000000 --- a/core/src/main/scala/cats/syntax/cartesian.scala +++ /dev/null @@ -1,20 +0,0 @@ -package cats -package syntax - -trait CartesianSyntax { - implicit final def catsSyntaxCartesian[F[_], A](fa: F[A])(implicit F: Cartesian[F]): CartesianOps[F, A] = - new CartesianOps[F, A] { - type TypeClassType = Cartesian[F] - - val self = fa - val typeClassInstance = F - } -} - -abstract class CartesianOps[F[_], A] extends Cartesian.Ops[F, A] { - - @deprecated("Replaced by an apply syntax, e.g. instead of (a |@| b).map(...) use (a, b).mapN(...)", "1.0.0-MF") - final def |@|[B](fb: F[B]): CartesianBuilder[F]#CartesianBuilder2[A, B] = - new CartesianBuilder[F] |@| self |@| fb - -} diff --git a/core/src/main/scala/cats/syntax/package.scala b/core/src/main/scala/cats/syntax/package.scala index f8c035de2a..3b2287fd9f 100644 --- a/core/src/main/scala/cats/syntax/package.scala +++ b/core/src/main/scala/cats/syntax/package.scala @@ -10,7 +10,7 @@ package object syntax { object bifunctor extends BifunctorSyntax object bifoldable extends BifoldableSyntax object bitraverse extends BitraverseSyntax - object cartesian extends CartesianSyntax + object semigroupal extends SemigroupalSyntax object coflatMap extends CoflatMapSyntax object eitherK extends EitherKSyntax object comonad extends ComonadSyntax diff --git a/core/src/main/scala/cats/syntax/semigroupal.scala b/core/src/main/scala/cats/syntax/semigroupal.scala new file mode 100644 index 0000000000..5defa832c3 --- /dev/null +++ b/core/src/main/scala/cats/syntax/semigroupal.scala @@ -0,0 +1,20 @@ +package cats +package syntax + +trait SemigroupalSyntax { + implicit final def catsSyntaxSemigroupal[F[_], A](fa: F[A])(implicit F: Semigroupal[F]): SemigroupalOps[F, A] = + new SemigroupalOps[F, A] { + type TypeClassType = Semigroupal[F] + + val self = fa + val typeClassInstance = F + } +} + +abstract class SemigroupalOps[F[_], A] extends Semigroupal.Ops[F, A] { + + @deprecated("Replaced by an apply syntax, e.g. instead of (a |@| b).map(...) use (a, b).mapN(...)", "1.0.0-MF") + final def |@|[B](fb: F[B]): SemigroupalBuilder[F]#SemigroupalBuilder2[A, B] = + new SemigroupalBuilder[F] |@| self |@| fb + +} diff --git a/docs/src/main/tut/datatypes/validated.md b/docs/src/main/tut/datatypes/validated.md index b082928476..1f72a10b5d 100644 --- a/docs/src/main/tut/datatypes/validated.md +++ b/docs/src/main/tut/datatypes/validated.md @@ -522,7 +522,7 @@ implicit def validatedApplicative[E : Semigroup]: Applicative[Validated[E, ?]] = ``` Awesome! And now we also get access to all the goodness of `Applicative`, which includes `map{2-22}`, as well as the -`Cartesian` tuple syntax. +`Semigroupal` tuple syntax. We can now easily ask for several bits of configuration and get any and all errors returned back. diff --git a/docs/src/main/tut/typeclasses/invariantmonoidal.md b/docs/src/main/tut/typeclasses/invariantmonoidal.md index fbf103df8f..7c01370d27 100644 --- a/docs/src/main/tut/typeclasses/invariantmonoidal.md +++ b/docs/src/main/tut/typeclasses/invariantmonoidal.md @@ -43,7 +43,7 @@ def product[A, B](fa: Semigroup[A], fb: Semigroup[B]): Semigroup[(A, B)] = } ``` -Given an instance of `InvariantMonoidal` for `Semigroup`, we are able to combine existing `Semigroup` instances to form a new `Semigroup` by using the `Cartesian` syntax: +Given an instance of `InvariantMonoidal` for `Semigroup`, we are able to combine existing `Semigroup` instances to form a new `Semigroup` by using the `Semigroupal` syntax: ```tut:silent import cats.implicits._ diff --git a/free/src/test/scala/cats/free/CofreeTests.scala b/free/src/test/scala/cats/free/CofreeTests.scala index 3558437648..3126771554 100644 --- a/free/src/test/scala/cats/free/CofreeTests.scala +++ b/free/src/test/scala/cats/free/CofreeTests.scala @@ -2,7 +2,7 @@ package cats package free import cats.data.{NonEmptyList, OptionT} -import cats.laws.discipline.{CartesianTests, ComonadTests, ReducibleTests, SerializableTests, TraverseTests} +import cats.laws.discipline.{SemigroupalTests, ComonadTests, ReducibleTests, SerializableTests, TraverseTests} import cats.syntax.list._ import cats.tests.{CatsSuite, Spooky} import org.scalacheck.{Arbitrary, Cogen, Gen} @@ -11,7 +11,7 @@ class CofreeTests extends CatsSuite { import CofreeTests._ - implicit val iso = CartesianTests.Isomorphisms.invariant[Cofree[Option, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Cofree[Option, ?]] checkAll("Cofree[Option, ?]", ComonadTests[Cofree[Option, ?]].comonad[Int, Int, Int]) locally { diff --git a/free/src/test/scala/cats/free/FreeApplicativeTests.scala b/free/src/test/scala/cats/free/FreeApplicativeTests.scala index d01a954ed3..05abf3ad5b 100644 --- a/free/src/test/scala/cats/free/FreeApplicativeTests.scala +++ b/free/src/test/scala/cats/free/FreeApplicativeTests.scala @@ -3,7 +3,7 @@ package free import cats.tests.CatsSuite import cats.arrow.FunctionK -import cats.laws.discipline.{CartesianTests, ApplicativeTests, SerializableTests} +import cats.laws.discipline.{SemigroupalTests, ApplicativeTests, SerializableTests} import cats.data.State import org.scalacheck.{Arbitrary, Gen} @@ -11,7 +11,7 @@ import org.scalacheck.{Arbitrary, Gen} class FreeApplicativeTests extends CatsSuite { import FreeApplicativeTests._ - implicit val iso = CartesianTests.Isomorphisms.invariant[FreeApplicative[Option, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[FreeApplicative[Option, ?]] checkAll("FreeApplicative[Option, ?]", ApplicativeTests[FreeApplicative[Option, ?]].applicative[Int, Int, Int]) checkAll("Applicative[FreeApplicative[Option, ?]]", SerializableTests.serializable(Applicative[FreeApplicative[Option, ?]])) diff --git a/free/src/test/scala/cats/free/FreeInvariantMonoidalTests.scala b/free/src/test/scala/cats/free/FreeInvariantMonoidalTests.scala index cbd287121c..e4a3fe3283 100644 --- a/free/src/test/scala/cats/free/FreeInvariantMonoidalTests.scala +++ b/free/src/test/scala/cats/free/FreeInvariantMonoidalTests.scala @@ -4,7 +4,7 @@ package tests import cats.arrow.FunctionK import cats.free.FreeInvariantMonoidal import cats.laws.discipline.{InvariantMonoidalTests, SerializableTests} -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Gen} import cats.tests.CsvCodecInvariantMonoidalTests._ diff --git a/free/src/test/scala/cats/free/FreeTTests.scala b/free/src/test/scala/cats/free/FreeTTests.scala index 51329cb8f8..d61b4eb782 100644 --- a/free/src/test/scala/cats/free/FreeTTests.scala +++ b/free/src/test/scala/cats/free/FreeTTests.scala @@ -173,7 +173,7 @@ trait FreeTTestsInstances { import IndexedStateT._ import cats.kernel.instances.option._ import cats.tests.IndexedStateTTests._ - import CartesianTests._ + import SemigroupalTests._ type IntState[A] = State[Int, A] type FreeTOption[A] = FreeT[Option, Option, A] @@ -181,9 +181,9 @@ trait FreeTTestsInstances { case class JustFunctor[A](a: A) - implicit val ftlWIso: Isomorphisms[FreeTOption] = CartesianTests.Isomorphisms.invariant[FreeTOption] + implicit val ftlWIso: Isomorphisms[FreeTOption] = SemigroupalTests.Isomorphisms.invariant[FreeTOption] - implicit val ftlSIso: Isomorphisms[FreeTState] = CartesianTests.Isomorphisms.invariant[FreeTState] + implicit val ftlSIso: Isomorphisms[FreeTState] = SemigroupalTests.Isomorphisms.invariant[FreeTState] implicit val jfFunctor: Functor[JustFunctor] = new Functor[JustFunctor] { override def map[A, B](fa: JustFunctor[A])(f: A => B): JustFunctor[B] = JustFunctor(f(fa.a)) diff --git a/free/src/test/scala/cats/free/FreeTests.scala b/free/src/test/scala/cats/free/FreeTests.scala index d8ee9c2ba7..7727437eea 100644 --- a/free/src/test/scala/cats/free/FreeTests.scala +++ b/free/src/test/scala/cats/free/FreeTests.scala @@ -3,7 +3,7 @@ package free import cats.arrow.FunctionK import cats.data.EitherK -import cats.laws.discipline.{CartesianTests, FoldableTests, MonadTests, SerializableTests, TraverseTests} +import cats.laws.discipline.{SemigroupalTests, FoldableTests, MonadTests, SerializableTests, TraverseTests} import cats.laws.discipline.arbitrary.catsLawsArbitraryForFn0 import cats.tests.CatsSuite @@ -13,7 +13,7 @@ import Arbitrary.arbFunction1 class FreeTests extends CatsSuite { import FreeTests._ - implicit val iso = CartesianTests.Isomorphisms.invariant[Free[Option, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Free[Option, ?]] checkAll("Free[Option, ?]", MonadTests[Free[Option, ?]].monad[Int, Int, Int]) checkAll("Monad[Free[Option, ?]]", SerializableTests.serializable(Monad[Free[Option, ?]])) diff --git a/laws/src/main/scala/cats/laws/ApplicativeLaws.scala b/laws/src/main/scala/cats/laws/ApplicativeLaws.scala index a615c2525a..a1405f09a0 100644 --- a/laws/src/main/scala/cats/laws/ApplicativeLaws.scala +++ b/laws/src/main/scala/cats/laws/ApplicativeLaws.scala @@ -39,7 +39,7 @@ trait ApplicativeLaws[F[_]] extends ApplyLaws[F] { F.unit.map(_ => a) <-> F.pure(a) // The following are the lax monoidal functor identity laws - the associativity law is covered by - // Cartesian's associativity law. + // Semigroupal's associativity law. def monoidalLeftIdentity[A](fa: F[A]): (F[(Unit, A)], F[A]) = (F.product(F.pure(()), fa), fa) diff --git a/laws/src/main/scala/cats/laws/ApplyLaws.scala b/laws/src/main/scala/cats/laws/ApplyLaws.scala index 34e2ee4773..a2543cc036 100644 --- a/laws/src/main/scala/cats/laws/ApplyLaws.scala +++ b/laws/src/main/scala/cats/laws/ApplyLaws.scala @@ -7,7 +7,7 @@ import cats.syntax.functor._ /** * Laws that must be obeyed by any `Apply`. */ -trait ApplyLaws[F[_]] extends FunctorLaws[F] with CartesianLaws[F] { +trait ApplyLaws[F[_]] extends FunctorLaws[F] with SemigroupalLaws[F] { implicit override def F: Apply[F] def applyComposition[A, B, C](fa: F[A], fab: F[A => B], fbc: F[B => C]): IsEq[F[C]] = { diff --git a/laws/src/main/scala/cats/laws/CartesianLaws.scala b/laws/src/main/scala/cats/laws/CartesianLaws.scala deleted file mode 100644 index 39a322d2e2..0000000000 --- a/laws/src/main/scala/cats/laws/CartesianLaws.scala +++ /dev/null @@ -1,17 +0,0 @@ -package cats -package laws - -/** - * Laws that must be obeyed by any `cats.Cartesian`. - */ -trait CartesianLaws[F[_]] { - implicit def F: Cartesian[F] - - def cartesianAssociativity[A, B, C](fa: F[A], fb: F[B], fc: F[C]): (F[(A, (B, C))], F[((A, B), C)]) = - (F.product(fa, F.product(fb, fc)), F.product(F.product(fa, fb), fc)) -} - -object CartesianLaws { - def apply[F[_]](implicit ev: Cartesian[F]): CartesianLaws[F] = - new CartesianLaws[F] { val F = ev } -} diff --git a/laws/src/main/scala/cats/laws/InvariantMonoidalLaws.scala b/laws/src/main/scala/cats/laws/InvariantMonoidalLaws.scala index ba701767e2..99ed3761ce 100644 --- a/laws/src/main/scala/cats/laws/InvariantMonoidalLaws.scala +++ b/laws/src/main/scala/cats/laws/InvariantMonoidalLaws.scala @@ -4,9 +4,9 @@ package laws /** * Laws that must be obeyed by any `cats.InvariantMonoidal`. */ -trait InvariantMonoidalLaws[F[_]] extends InvariantLaws[F] with CartesianLaws[F] { +trait InvariantMonoidalLaws[F[_]] extends InvariantLaws[F] with SemigroupalLaws[F] { override implicit def F: InvariantMonoidal[F] - import cats.syntax.cartesian._ + import cats.syntax.semigroupal._ import cats.syntax.invariant._ def invariantMonoidalLeftIdentity[A, B](fa: F[A], b: B): IsEq[F[A]] = diff --git a/laws/src/main/scala/cats/laws/SemigroupalLaws.scala b/laws/src/main/scala/cats/laws/SemigroupalLaws.scala new file mode 100644 index 0000000000..59cdbc363f --- /dev/null +++ b/laws/src/main/scala/cats/laws/SemigroupalLaws.scala @@ -0,0 +1,17 @@ +package cats +package laws + +/** + * Laws that must be obeyed by any `cats.Semigroupal`. + */ +trait SemigroupalLaws[F[_]] { + implicit def F: Semigroupal[F] + + def semigroupalAssociativity[A, B, C](fa: F[A], fb: F[B], fc: F[C]): (F[(A, (B, C))], F[((A, B), C)]) = + (F.product(fa, F.product(fb, fc)), F.product(F.product(fa, fb), fc)) +} + +object SemigroupalLaws { + def apply[F[_]](implicit ev: Semigroupal[F]): SemigroupalLaws[F] = + new SemigroupalLaws[F] { val F = ev } +} diff --git a/laws/src/main/scala/cats/laws/discipline/AlternativeTests.scala b/laws/src/main/scala/cats/laws/discipline/AlternativeTests.scala index 8a11fc7a05..832ad97efb 100644 --- a/laws/src/main/scala/cats/laws/discipline/AlternativeTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/AlternativeTests.scala @@ -2,7 +2,7 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ diff --git a/laws/src/main/scala/cats/laws/discipline/ApplicativeErrorTests.scala b/laws/src/main/scala/cats/laws/discipline/ApplicativeErrorTests.scala index 8e52d7acaf..6edc466d0b 100644 --- a/laws/src/main/scala/cats/laws/discipline/ApplicativeErrorTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/ApplicativeErrorTests.scala @@ -3,7 +3,7 @@ package laws package discipline import cats.data.EitherT -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import cats.laws.discipline.arbitrary._ import org.scalacheck.{Arbitrary, Cogen, Prop} import org.scalacheck.Prop.forAll diff --git a/laws/src/main/scala/cats/laws/discipline/ApplicativeTests.scala b/laws/src/main/scala/cats/laws/discipline/ApplicativeTests.scala index 6904efab24..e7990de517 100644 --- a/laws/src/main/scala/cats/laws/discipline/ApplicativeTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/ApplicativeTests.scala @@ -2,7 +2,7 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ diff --git a/laws/src/main/scala/cats/laws/discipline/ApplyTests.scala b/laws/src/main/scala/cats/laws/discipline/ApplyTests.scala index 88a1526489..7288a59514 100644 --- a/laws/src/main/scala/cats/laws/discipline/ApplyTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/ApplyTests.scala @@ -2,11 +2,11 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ -trait ApplyTests[F[_]] extends FunctorTests[F] with CartesianTests[F] { +trait ApplyTests[F[_]] extends FunctorTests[F] with SemigroupalTests[F] { def laws: ApplyLaws[F] def apply[A: Arbitrary, B: Arbitrary, C: Arbitrary](implicit @@ -24,7 +24,7 @@ trait ApplyTests[F[_]] extends FunctorTests[F] with CartesianTests[F] { iso: Isomorphisms[F] ): RuleSet = new RuleSet { val name = "apply" - val parents = Seq(functor[A, B, C], cartesian[A, B, C]) + val parents = Seq(functor[A, B, C], semigroupal[A, B, C]) val bases = Seq.empty val props = Seq( "apply composition" -> forAll(laws.applyComposition[A, B, C] _), diff --git a/laws/src/main/scala/cats/laws/discipline/BimonadTests.scala b/laws/src/main/scala/cats/laws/discipline/BimonadTests.scala index 69e4eb3182..a8f3dd21fc 100644 --- a/laws/src/main/scala/cats/laws/discipline/BimonadTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/BimonadTests.scala @@ -2,7 +2,7 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ diff --git a/laws/src/main/scala/cats/laws/discipline/CommutativeFlatMapTests.scala b/laws/src/main/scala/cats/laws/discipline/CommutativeFlatMapTests.scala index 70a69fe2bd..c01c707a59 100644 --- a/laws/src/main/scala/cats/laws/discipline/CommutativeFlatMapTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/CommutativeFlatMapTests.scala @@ -2,7 +2,7 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ diff --git a/laws/src/main/scala/cats/laws/discipline/CommutativeMonadTests.scala b/laws/src/main/scala/cats/laws/discipline/CommutativeMonadTests.scala index c2a0975759..243f4ea735 100644 --- a/laws/src/main/scala/cats/laws/discipline/CommutativeMonadTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/CommutativeMonadTests.scala @@ -2,7 +2,7 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} trait CommutativeMonadTests[F[_]] extends MonadTests[F] with CommutativeFlatMapTests[F] { diff --git a/laws/src/main/scala/cats/laws/discipline/FlatMapTests.scala b/laws/src/main/scala/cats/laws/discipline/FlatMapTests.scala index 47beaad858..a1cd927f29 100644 --- a/laws/src/main/scala/cats/laws/discipline/FlatMapTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/FlatMapTests.scala @@ -4,7 +4,7 @@ package discipline import cats.instances.eq._ -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ @@ -28,7 +28,7 @@ trait FlatMapTests[F[_]] extends ApplyTests[F] { ): RuleSet = { implicit def functorF: Functor[F] = laws.F implicit val EqFAB: Eq[F[(A, B)]] = - ContravariantCartesian[Eq].composeFunctor[F].product(EqFA, EqFB) + ContravariantSemigroupal[Eq].composeFunctor[F].product(EqFA, EqFB) new DefaultRuleSet( name = "flatMap", diff --git a/laws/src/main/scala/cats/laws/discipline/InvariantMonoidalTests.scala b/laws/src/main/scala/cats/laws/discipline/InvariantMonoidalTests.scala index 0d44206d47..16bec176d3 100644 --- a/laws/src/main/scala/cats/laws/discipline/InvariantMonoidalTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/InvariantMonoidalTests.scala @@ -2,11 +2,11 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen} import org.scalacheck.Prop._ -trait InvariantMonoidalTests[F[_]] extends InvariantTests[F] with CartesianTests[F] { +trait InvariantMonoidalTests[F[_]] extends InvariantTests[F] with SemigroupalTests[F] { def laws: InvariantMonoidalLaws[F] def invariantMonoidal[A: Arbitrary, B: Arbitrary, C: Arbitrary](implicit @@ -24,12 +24,12 @@ trait InvariantMonoidalTests[F[_]] extends InvariantTests[F] with CartesianTests ): RuleSet = new RuleSet { val name = "invariantMonoidal" - val parents = Seq(invariant[A, B, C], cartesian[A, B, C]) + val parents = Seq(invariant[A, B, C], semigroupal[A, B, C]) val bases = Seq.empty val props = Seq( - "invariant cartesian left identity" -> forAll((fa: F[A], b: B) => laws.invariantMonoidalLeftIdentity(fa, b)), - "invariant cartesian right identity" -> forAll((fa: F[A], b: B) => laws.invariantMonoidalRightIdentity(fa, b)), - "invariant cartesian associativity" -> forAll((fa: F[A], fb: F[B], fc: F[C]) => laws.invariantMonoidalAssociativity(fa, fb, fc)) + "invariant semigroupal left identity" -> forAll((fa: F[A], b: B) => laws.invariantMonoidalLeftIdentity(fa, b)), + "invariant semigroupal right identity" -> forAll((fa: F[A], b: B) => laws.invariantMonoidalRightIdentity(fa, b)), + "invariant semigroupal associativity" -> forAll((fa: F[A], fb: F[B], fc: F[C]) => laws.invariantMonoidalAssociativity(fa, fb, fc)) ) } } diff --git a/laws/src/main/scala/cats/laws/discipline/MonadErrorTests.scala b/laws/src/main/scala/cats/laws/discipline/MonadErrorTests.scala index c6a6a4d5c8..f63cdfa111 100644 --- a/laws/src/main/scala/cats/laws/discipline/MonadErrorTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/MonadErrorTests.scala @@ -3,7 +3,7 @@ package laws package discipline import cats.data.EitherT -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import org.scalacheck.Prop.forAll diff --git a/laws/src/main/scala/cats/laws/discipline/MonadTests.scala b/laws/src/main/scala/cats/laws/discipline/MonadTests.scala index 669bd5ec42..2ac2aa16e2 100644 --- a/laws/src/main/scala/cats/laws/discipline/MonadTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/MonadTests.scala @@ -3,7 +3,7 @@ package laws package discipline import catalysts.Platform -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.{Arbitrary, Cogen, Prop} import Prop._ diff --git a/laws/src/main/scala/cats/laws/discipline/CartesianTests.scala b/laws/src/main/scala/cats/laws/discipline/SemigroupalTests.scala similarity index 70% rename from laws/src/main/scala/cats/laws/discipline/CartesianTests.scala rename to laws/src/main/scala/cats/laws/discipline/SemigroupalTests.scala index 38dd1b2614..228d8e9cad 100644 --- a/laws/src/main/scala/cats/laws/discipline/CartesianTests.scala +++ b/laws/src/main/scala/cats/laws/discipline/SemigroupalTests.scala @@ -2,16 +2,16 @@ package cats package laws package discipline -import cats.laws.discipline.CartesianTests.Isomorphisms +import cats.laws.discipline.SemigroupalTests.Isomorphisms import org.scalacheck.Arbitrary import org.scalacheck.Prop import Prop._ import org.typelevel.discipline.Laws -trait CartesianTests[F[_]] extends Laws { - def laws: CartesianLaws[F] +trait SemigroupalTests[F[_]] extends Laws { + def laws: SemigroupalLaws[F] - def cartesian[A : Arbitrary, B : Arbitrary, C : Arbitrary](implicit + def semigroupal[A : Arbitrary, B : Arbitrary, C : Arbitrary](implicit iso: Isomorphisms[F], ArbFA: Arbitrary[F[A]], ArbFB: Arbitrary[F[B]], @@ -20,16 +20,16 @@ trait CartesianTests[F[_]] extends Laws { EqFABC: Eq[F[(A, B, C)]] ): RuleSet = { new DefaultRuleSet( - name = "cartesian", + name = "semigroupal", parent = None, - "cartesian associativity" -> forAll((fa: F[A], fb: F[B], fc: F[C]) => iso.associativity(laws.cartesianAssociativity(fa, fb, fc))) + "semigroupal associativity" -> forAll((fa: F[A], fb: F[B], fc: F[C]) => iso.associativity(laws.semigroupalAssociativity(fa, fb, fc))) ) } } -object CartesianTests { - def apply[F[_] : Cartesian](implicit ev: Isomorphisms[F]): CartesianTests[F] = - new CartesianTests[F] { val laws: CartesianLaws[F] = CartesianLaws[F] } +object SemigroupalTests { + def apply[F[_] : Semigroupal](implicit ev: Isomorphisms[F]): SemigroupalTests[F] = + new SemigroupalTests[F] { val laws: SemigroupalLaws[F] = SemigroupalLaws[F] } trait Isomorphisms[F[_]] { def associativity[A, B, C](fs: (F[(A, (B, C))], F[((A, B), C)])): IsEq[F[(A, B, C)]] diff --git a/project/Boilerplate.scala b/project/Boilerplate.scala index e2626a107d..a556823196 100644 --- a/project/Boilerplate.scala +++ b/project/Boilerplate.scala @@ -25,10 +25,10 @@ object Boilerplate { val templates: Seq[Template] = Seq( - GenCartesianBuilders, - GenCartesianArityFunctions, + GenSemigroupalBuilders, + GenSemigroupalArityFunctions, GenApplyArityFunctions, - GenTupleCartesianSyntax + GenTupleSemigroupalSyntax ) val header = "// auto-generated boilerplate" // TODO: put something meaningful here? @@ -95,8 +95,8 @@ object Boilerplate { The block otherwise behaves as a standard interpolated string with regards to variable substitution. */ - object GenCartesianBuilders extends Template { - def filename(root: File) = root / "cats" / "syntax" / "CartesianBuilder.scala" + object GenSemigroupalBuilders extends Template { + def filename(root: File) = root / "cats" / "syntax" / "SemigroupalBuilder.scala" def content(tv: TemplateVals) = { import tv._ @@ -105,7 +105,7 @@ object Boilerplate { val tpesString = synTypes mkString ", " val params = (synVals zip tpes) map { case (v,t) => s"$v:$t"} mkString ", " val next = if (arity + 1 <= maxArity) { - s"def |@|[Z](z: F[Z]) = new CartesianBuilder${arity + 1}(${`a..n`}, z)" + s"def |@|[Z](z: F[Z]) = new SemigroupalBuilder${arity + 1}(${`a..n`}, z)" } else { "" } @@ -114,18 +114,18 @@ object Boilerplate { val map = if (arity == 1) s"def map[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F]): F[Z] = functor.map(${`a..n`})(f)" - else s"def map[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F], cartesian: Cartesian[F]): F[Z] = Cartesian.map$n(${`a..n`})(f)" + else s"def map[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.map$n(${`a..n`})(f)" val contramap = if (arity == 1) s"def contramap[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F]): F[Z] = contravariant.contramap(${`a..n`})(f)" - else s"def contramap[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F], cartesian: Cartesian[F]): F[Z] = Cartesian.contramap$n(${`a..n`})(f)" + else s"def contramap[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.contramap$n(${`a..n`})(f)" val imap = if (arity == 1) s"def imap[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F]): F[Z] = invariant.imap(${`a..n`})(f)(g)" - else s"def imap[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F], cartesian: Cartesian[F]): F[Z] = Cartesian.imap$n(${`a..n`})(f)(g)" + else s"def imap[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.imap$n(${`a..n`})(f)(g)" val tupled = if (arity != 1) { - s"def tupled(implicit invariant: Invariant[F], cartesian: Cartesian[F]): F[(${`A..N`})] = Cartesian.tuple$n(${`a..n`})" + s"def tupled(implicit invariant: Invariant[F], semigroupal: Semigroupal[F]): F[(${`A..N`})] = Semigroupal.tuple$n(${`a..n`})" } else { "" } @@ -137,10 +137,10 @@ object Boilerplate { | | |@deprecated("replaced by apply syntax", "1.0.0-MF") - |private[syntax] final class CartesianBuilder[F[_]] { - | def |@|[A](a: F[A]) = new CartesianBuilder1(a) + |private[syntax] final class SemigroupalBuilder[F[_]] { + | def |@|[A](a: F[A]) = new SemigroupalBuilder1(a) | - - private[syntax] final class CartesianBuilder$arity[${`A..N`}]($params) { + - private[syntax] final class SemigroupalBuilder$arity[${`A..N`}]($params) { - $next - def apWith[Z](f: F[(${`A..N`}) => Z])(implicit apply: Apply[F]): F[Z] = apply.ap$n(f)(${`a..n`}) - $map @@ -183,17 +183,17 @@ object Boilerplate { block""" |package cats |trait ApplyArityFunctions[F[_]] { self: Apply[F] => - | def tuple2[A, B](f1: F[A], f2: F[B]): F[(A, B)] = Cartesian.tuple2(f1, f2)(self, self) + | def tuple2[A, B](f1: F[A], f2: F[B]): F[(A, B)] = Semigroupal.tuple2(f1, f2)(self, self) - def ap$arity[${`A..N`}, Z](f: F[(${`A..N`}) => Z])($fparams):F[Z] = $apply - - def map$arity[${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z): F[Z] = Cartesian.map$arity($fparams)(f)(self, self) - - def tuple$arity[${`A..N`}, Z]($fparams): F[(${`A..N`})] = Cartesian.tuple$arity($fparams)(self, self) + - def map$arity[${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z): F[Z] = Semigroupal.map$arity($fparams)(f)(self, self) + - def tuple$arity[${`A..N`}, Z]($fparams): F[(${`A..N`})] = Semigroupal.tuple$arity($fparams)(self, self) |} """ } } - object GenCartesianArityFunctions extends Template { - def filename(root: File) = root / "cats" / "CartesianArityFunctions.scala" + object GenSemigroupalArityFunctions extends Template { + def filename(root: File) = root / "cats" / "SemigroupalArityFunctions.scala" override def range = 2 to maxArity def content(tv: TemplateVals) = { import tv._ @@ -203,29 +203,29 @@ object Boilerplate { val fparams = (fargs zip tpes) map { case (v,t) => s"$v:$t"} mkString ", " val fargsS = fargs mkString ", " - val nestedProducts = (0 until (arity - 2)).foldRight(s"cartesian.product(f${arity - 2}, f${arity - 1})")((i, acc) => s"cartesian.product(f$i, $acc)") + val nestedProducts = (0 until (arity - 2)).foldRight(s"semigroupal.product(f${arity - 2}, f${arity - 1})")((i, acc) => s"semigroupal.product(f$i, $acc)") val `nested (a..n)` = (0 until (arity - 2)).foldRight(s"(a${arity - 2}, a${arity - 1})")((i, acc) => s"(a$i, $acc)") block""" |package cats - |trait CartesianArityFunctions { - - def map$arity[F[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z)(implicit cartesian: Cartesian[F], functor: Functor[F]): F[Z] = + |trait SemigroupalArityFunctions { + - def map$arity[F[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z)(implicit semigroupal: Semigroupal[F], functor: Functor[F]): F[Z] = - functor.map($nestedProducts) { case ${`nested (a..n)`} => f(${`a..n`}) } - - def contramap$arity[F[_], ${`A..N`}, Z]($fparams)(f: Z => (${`A..N`}))(implicit cartesian: Cartesian[F], contravariant: Contravariant[F]):F[Z] = + - def contramap$arity[F[_], ${`A..N`}, Z]($fparams)(f: Z => (${`A..N`}))(implicit semigroupal: Semigroupal[F], contravariant: Contravariant[F]):F[Z] = - contravariant.contramap($nestedProducts) { z => val ${`(a..n)`} = f(z); ${`nested (a..n)`} } - - def imap$arity[F[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit cartesian: Cartesian[F], invariant: Invariant[F]):F[Z] = + - def imap$arity[F[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit semigroupal: Semigroupal[F], invariant: Invariant[F]):F[Z] = - invariant.imap($nestedProducts) { case ${`nested (a..n)`} => f(${`a..n`}) } { z => val ${`(a..n)`} = g(z); ${`nested (a..n)`} } - - def tuple$arity[F[_], ${`A..N`}]($fparams)(implicit cartesian: Cartesian[F], invariant: Invariant[F]):F[(${`A..N`})] = + - def tuple$arity[F[_], ${`A..N`}]($fparams)(implicit semigroupal: Semigroupal[F], invariant: Invariant[F]):F[(${`A..N`})] = - imap$arity($fargsS)((${`_.._`}))(identity) - - def traverse$arity[F[_], G[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => G[Z])(implicit cartesian: Cartesian[F], traverse: Traverse[F], applicative: Applicative[G]): G[F[Z]] = + - def traverse$arity[F[_], G[_], ${`A..N`}, Z]($fparams)(f: (${`A..N`}) => G[Z])(implicit semigroupal: Semigroupal[F], traverse: Traverse[F], applicative: Applicative[G]): G[F[Z]] = - traverse.traverse($nestedProducts) { case ${`nested (a..n)`} => f(${`a..n`}) } |} """ } } - object GenTupleCartesianSyntax extends Template { - def filename(root: File) = root / "cats" / "syntax" / "TupleCartesianSyntax.scala" + object GenTupleSemigroupalSyntax extends Template { + def filename(root: File) = root / "cats" / "syntax" / "TupleSemigroupalSyntax.scala" def content(tv: TemplateVals) = { import tv._ @@ -241,25 +241,25 @@ object Boilerplate { val map = if (arity == 1) s"def map[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F]): F[Z] = functor.map($tupleArgs)(f)" - else s"def mapN[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F], cartesian: Cartesian[F]): F[Z] = Cartesian.map$arity($tupleArgs)(f)" + else s"def mapN[Z](f: (${`A..N`}) => Z)(implicit functor: Functor[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.map$arity($tupleArgs)(f)" val contramap = if (arity == 1) s"def contramap[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F]): F[Z] = contravariant.contramap($tupleArgs)(f)" - else s"def contramapN[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F], cartesian: Cartesian[F]): F[Z] = Cartesian.contramap$arity($tupleArgs)(f)" + else s"def contramapN[Z](f: Z => (${`A..N`}))(implicit contravariant: Contravariant[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.contramap$arity($tupleArgs)(f)" val imap = if (arity == 1) s"def imap[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F]): F[Z] = invariant.imap($tupleArgs)(f)(g)" - else s"def imapN[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F], cartesian: Cartesian[F]): F[Z] = Cartesian.imap$arity($tupleArgs)(f)(g)" + else s"def imapN[Z](f: (${`A..N`}) => Z)(g: Z => (${`A..N`}))(implicit invariant: Invariant[F], semigroupal: Semigroupal[F]): F[Z] = Semigroupal.imap$arity($tupleArgs)(f)(g)" val tupled = if (arity != 1) { - s"def tupled(implicit invariant: Invariant[F], cartesian: Cartesian[F]): F[(${`A..N`})] = Cartesian.tuple$n($tupleArgs)" + s"def tupled(implicit invariant: Invariant[F], semigroupal: Semigroupal[F]): F[(${`A..N`})] = Semigroupal.tuple$n($tupleArgs)" } else { "" } val traverse = if (arity == 1) s"def traverse[G[_]: Applicative, Z](f: (${`A..N`}) => G[Z])(implicit traverse: Traverse[F]): G[F[Z]] = traverse.traverse($tupleArgs)(f)" - else s"def traverseN[G[_]: Applicative, Z](f: (${`A..N`}) => G[Z])(implicit traverse: Traverse[F], cartesian: Cartesian[F]): G[F[Z]] = Cartesian.traverse$arity($tupleArgs)(f)" + else s"def traverseN[G[_]: Applicative, Z](f: (${`A..N`}) => G[Z])(implicit traverse: Traverse[F], semigroupal: Semigroupal[F]): G[F[Z]] = Semigroupal.traverse$arity($tupleArgs)(f)" block""" @@ -268,11 +268,11 @@ object Boilerplate { | | | - |trait TupleCartesianSyntax { - - implicit def catsSyntaxTuple${arity}Cartesian[F[_], ${`A..N`}]($tupleTpe): Tuple${arity}CartesianOps[F, ${`A..N`}] = new Tuple${arity}CartesianOps(t$arity) + |trait TupleSemigroupalSyntax { + - implicit def catsSyntaxTuple${arity}Semigroupal[F[_], ${`A..N`}]($tupleTpe): Tuple${arity}SemigroupalOps[F, ${`A..N`}] = new Tuple${arity}SemigroupalOps(t$arity) |} | - -private[syntax] final class Tuple${arity}CartesianOps[F[_], ${`A..N`}]($tupleTpe) { + -private[syntax] final class Tuple${arity}SemigroupalOps[F[_], ${`A..N`}]($tupleTpe) { - $map - $contramap - $imap diff --git a/tests/src/test/scala/cats/tests/CokleisliTests.scala b/tests/src/test/scala/cats/tests/CokleisliTests.scala index 9c3a712cdc..74fd48d846 100644 --- a/tests/src/test/scala/cats/tests/CokleisliTests.scala +++ b/tests/src/test/scala/cats/tests/CokleisliTests.scala @@ -22,10 +22,10 @@ class CokleisliTests extends SlowCatsSuite { def cokleisliEqE[F[_], A](implicit A: Arbitrary[F[A]], FA: Eq[A]): Eq[Cokleisli[F, A, A]] = Eq.by[Cokleisli[F, A, A], F[A] => A](_.run) - implicit val iso = CartesianTests.Isomorphisms.invariant[Cokleisli[Option, Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Cokleisli[Option, Int, ?]] - checkAll("Cokleisli[Option, Int, Int]", CartesianTests[Cokleisli[Option, Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Cokleisli[Option, Int, ?]]", SerializableTests.serializable(Cartesian[Cokleisli[Option, Int, ?]])) + checkAll("Cokleisli[Option, Int, Int]", SemigroupalTests[Cokleisli[Option, Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Cokleisli[Option, Int, ?]]", SerializableTests.serializable(Semigroupal[Cokleisli[Option, Int, ?]])) checkAll("Cokleisli[Option, Int, Int]", MonadTests[Cokleisli[Option, Int, ?]].monad[Int, Int, Int]) checkAll("Monad[Cokleisli[Option, Int, ?]]", SerializableTests.serializable(Monad[Cokleisli[Option, Int, ?]])) diff --git a/tests/src/test/scala/cats/tests/ConstTests.scala b/tests/src/test/scala/cats/tests/ConstTests.scala index 7eb43fa952..06ea6323f1 100644 --- a/tests/src/test/scala/cats/tests/ConstTests.scala +++ b/tests/src/test/scala/cats/tests/ConstTests.scala @@ -16,10 +16,10 @@ import cats.laws.discipline.arbitrary._ class ConstTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Const[String, ?]](Const.catsDataTraverseForConst) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Const[String, ?]](Const.catsDataTraverseForConst) - checkAll("Const[String, Int]", CartesianTests[Const[String, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Const[String, ?]]", SerializableTests.serializable(Cartesian[Const[String, ?]])) + checkAll("Const[String, Int]", SemigroupalTests[Const[String, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Const[String, ?]]", SerializableTests.serializable(Semigroupal[Const[String, ?]])) checkAll("Const[String, Int]", ApplicativeTests[Const[String, ?]].applicative[Int, Int, Int]) checkAll("Applicative[Const[String, ?]]", SerializableTests.serializable(Applicative[Const[String, ?]])) @@ -30,7 +30,7 @@ class ConstTests extends CatsSuite { // Get Apply[Const[C : Semigroup, ?]], not Applicative[Const[C : Monoid, ?]] { implicit def nonEmptyListSemigroup[A]: Semigroup[NonEmptyList[A]] = SemigroupK[NonEmptyList].algebra - implicit val iso = CartesianTests.Isomorphisms.invariant[Const[NonEmptyList[String], ?]](Const.catsDataContravariantForConst) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Const[NonEmptyList[String], ?]](Const.catsDataContravariantForConst) checkAll("Apply[Const[NonEmptyList[String], Int]]", ApplyTests[Const[NonEmptyList[String], ?]].apply[Int, Int, Int]) checkAll("Apply[Const[NonEmptyList[String], ?]]", SerializableTests.serializable(Apply[Const[NonEmptyList[String], ?]])) } diff --git a/tests/src/test/scala/cats/tests/EitherTTests.scala b/tests/src/test/scala/cats/tests/EitherTTests.scala index 3c167e048d..805978007a 100644 --- a/tests/src/test/scala/cats/tests/EitherTTests.scala +++ b/tests/src/test/scala/cats/tests/EitherTTests.scala @@ -16,7 +16,7 @@ EqLawTests class EitherTTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[EitherT[ListWrapper, String, ?]](EitherT.catsDataFunctorForEitherT(ListWrapper.functor)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[EitherT[ListWrapper, String, ?]](EitherT.catsDataFunctorForEitherT(ListWrapper.functor)) { checkAll("EitherT[Option, ListWrapper[String], ?]", SemigroupKTests[EitherT[Option, ListWrapper[String], ?]].semigroupK[Int]) diff --git a/tests/src/test/scala/cats/tests/EitherTests.scala b/tests/src/test/scala/cats/tests/EitherTests.scala index 72da1d6024..86a09bb317 100644 --- a/tests/src/test/scala/cats/tests/EitherTests.scala +++ b/tests/src/test/scala/cats/tests/EitherTests.scala @@ -13,13 +13,13 @@ import cats.kernel.laws.discipline.{ import scala.util.Try class EitherTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Either[Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Either[Int, ?]] checkAll("Either[String, Int]", MonoidLawTests[Either[String, Int]].monoid) checkAll("Monoid[Either[String, Int]]", SerializableTests.serializable(Monoid[Either[String, Int]])) - checkAll("Either[Int, Int]", CartesianTests[Either[Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Either[Int, ?]]", SerializableTests.serializable(Cartesian[Either[Int, ?]])) + checkAll("Either[Int, Int]", SemigroupalTests[Either[Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Either[Int, ?]]", SerializableTests.serializable(Semigroupal[Either[Int, ?]])) implicit val eq0 = EitherT.catsDataEqForEitherT[Either[Int, ?], Int, Int] diff --git a/tests/src/test/scala/cats/tests/EqTests.scala b/tests/src/test/scala/cats/tests/EqTests.scala index b62a756fa7..9790482255 100644 --- a/tests/src/test/scala/cats/tests/EqTests.scala +++ b/tests/src/test/scala/cats/tests/EqTests.scala @@ -10,15 +10,15 @@ class EqTests extends FunSuite { import cats.implicits._ Invariant[Eq] Contravariant[Eq] - Cartesian[Eq] - ContravariantCartesian[Eq] + Semigroupal[Eq] + ContravariantSemigroupal[Eq] } { import cats.instances.eq._ Invariant[Eq] Contravariant[Eq] - Cartesian[Eq] - ContravariantCartesian[Eq] + Semigroupal[Eq] + ContravariantSemigroupal[Eq] } } diff --git a/tests/src/test/scala/cats/tests/EquivTests.scala b/tests/src/test/scala/cats/tests/EquivTests.scala index 7538d21679..d1cedee4aa 100644 --- a/tests/src/test/scala/cats/tests/EquivTests.scala +++ b/tests/src/test/scala/cats/tests/EquivTests.scala @@ -10,10 +10,10 @@ class EquivTests extends CatsSuite { Invariant[Equiv] Contravariant[Equiv] - Cartesian[Equiv] - ContravariantCartesian[Equiv] + Semigroupal[Equiv] + ContravariantSemigroupal[Equiv] checkAll("Contravariant[Equiv]", ContravariantTests[Equiv].contravariant[Int, Int, Int]) - checkAll("Cartesian[Equiv]", CartesianTests[Equiv].cartesian[Int, Int, Int]) + checkAll("Semigroupal[Equiv]", SemigroupalTests[Equiv].semigroupal[Int, Int, Int]) checkAll("Contravariant[Equiv]", SerializableTests.serializable(Contravariant[Equiv])) } diff --git a/tests/src/test/scala/cats/tests/EvalTests.scala b/tests/src/test/scala/cats/tests/EvalTests.scala index 86ff9bee15..17c08a3a88 100644 --- a/tests/src/test/scala/cats/tests/EvalTests.scala +++ b/tests/src/test/scala/cats/tests/EvalTests.scala @@ -2,7 +2,7 @@ package cats package tests import cats.laws.ComonadLaws -import cats.laws.discipline.{BimonadTests, CartesianTests, ReducibleTests, SerializableTests} +import cats.laws.discipline.{BimonadTests, SemigroupalTests, ReducibleTests, SerializableTests} import cats.laws.discipline.arbitrary._ import cats.kernel.laws.discipline._ import org.scalacheck.{Arbitrary, Cogen, Gen} @@ -89,7 +89,7 @@ class EvalTests extends CatsSuite { } { - implicit val iso = CartesianTests.Isomorphisms.invariant[Eval] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Eval] checkAll("Eval[Int]", BimonadTests[Eval].bimonad[Int, Int, Int]) } diff --git a/tests/src/test/scala/cats/tests/FuncTests.scala b/tests/src/test/scala/cats/tests/FuncTests.scala index 4c2f0c669e..8b3e8a45e4 100644 --- a/tests/src/test/scala/cats/tests/FuncTests.scala +++ b/tests/src/test/scala/cats/tests/FuncTests.scala @@ -15,10 +15,10 @@ class FuncTests extends CatsSuite { implicit def appFuncEq[F[_], A, B](implicit A: Arbitrary[A], FB: Eq[F[B]]): Eq[AppFunc[F, A, B]] = Eq.by[AppFunc[F, A, B], A => F[B]](_.run) - implicit val iso = CartesianTests.Isomorphisms.invariant[Func[Option, Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Func[Option, Int, ?]] - checkAll("Func[Option, Int, Int]", CartesianTests[Func[Option, Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Func[Option, Int, ?]]", SerializableTests.serializable(Cartesian[Func[Option, Int, ?]])) + checkAll("Func[Option, Int, Int]", SemigroupalTests[Func[Option, Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Func[Option, Int, ?]]", SerializableTests.serializable(Semigroupal[Func[Option, Int, ?]])) { implicit val catsDataApplicativeForFunc = Func.catsDataApplicativeForFunc[Option, Int] @@ -46,7 +46,7 @@ class FuncTests extends CatsSuite { { implicit val appFuncApp = AppFunc.appFuncApplicative[Option, Int] - implicit val iso = CartesianTests.Isomorphisms.invariant[AppFunc[Option, Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[AppFunc[Option, Int, ?]] checkAll("AppFunc[Option, Int, Int]", ApplicativeTests[AppFunc[Option, Int, ?]].applicative[Int, Int, Int]) checkAll("Applicative[AppFunc[Option, Int, ?]]", SerializableTests.serializable(Applicative[AppFunc[Option, Int, ?]])) } diff --git a/tests/src/test/scala/cats/tests/FunctionTests.scala b/tests/src/test/scala/cats/tests/FunctionTests.scala index 36db548603..bf40a7d956 100644 --- a/tests/src/test/scala/cats/tests/FunctionTests.scala +++ b/tests/src/test/scala/cats/tests/FunctionTests.scala @@ -15,15 +15,15 @@ class FunctionTests extends CatsSuite { import Helpers._ - checkAll("Function0[Int]", CartesianTests[Function0].cartesian[Int, Int, Int]) - checkAll("Cartesian[Function0]", SerializableTests.serializable(Cartesian[Function0])) + checkAll("Function0[Int]", SemigroupalTests[Function0].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Function0]", SerializableTests.serializable(Semigroupal[Function0])) checkAll("Function0[Int]", BimonadTests[Function0].bimonad[Int, Int, Int]) checkAll("Bimonad[Function0]", SerializableTests.serializable(Bimonad[Function0])) - implicit val iso = CartesianTests.Isomorphisms.invariant[Function1[Int, ?]] - checkAll("Function1[Int, Int]", CartesianTests[Function1[Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Function1[Int, ?]]", SerializableTests.serializable(Cartesian[Function1[Int, ?]])) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Function1[Int, ?]] + checkAll("Function1[Int, Int]", SemigroupalTests[Function1[Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Function1[Int, ?]]", SerializableTests.serializable(Semigroupal[Function1[Int, ?]])) checkAll("Function1[Int, Int]", MonadTests[Int => ?].monad[Int, Int, Int]) checkAll("Monad[Int => ?]", SerializableTests.serializable(Monad[Int => ?])) diff --git a/tests/src/test/scala/cats/tests/IdTTests.scala b/tests/src/test/scala/cats/tests/IdTTests.scala index 1a2016f4fb..44824087d8 100644 --- a/tests/src/test/scala/cats/tests/IdTTests.scala +++ b/tests/src/test/scala/cats/tests/IdTTests.scala @@ -11,7 +11,7 @@ import cats.laws.discipline.arbitrary._ class IdTTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[IdT[ListWrapper, ?]](IdT.catsDataFunctorForIdT(ListWrapper.functor)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[IdT[ListWrapper, ?]](IdT.catsDataFunctorForIdT(ListWrapper.functor)) { implicit val F = ListWrapper.eqv[Option[Int]] diff --git a/tests/src/test/scala/cats/tests/IdTests.scala b/tests/src/test/scala/cats/tests/IdTests.scala index a991b9a03a..1040a08abd 100644 --- a/tests/src/test/scala/cats/tests/IdTests.scala +++ b/tests/src/test/scala/cats/tests/IdTests.scala @@ -4,7 +4,7 @@ package tests import cats.laws.discipline._ class IdTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Id] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Id] checkAll("Id[Int]", BimonadTests[Id].bimonad[Int, Int, Int]) checkAll("Bimonad[Id]", SerializableTests.serializable(Bimonad[Id])) diff --git a/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTTests.scala b/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTTests.scala index d34a85bd45..e319f8ccfa 100644 --- a/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTTests.scala +++ b/tests/src/test/scala/cats/tests/IndexedReaderWriterStateTTests.scala @@ -199,7 +199,7 @@ class ReaderWriterStateTTests extends CatsSuite { } } - test("Cartesian syntax is usable on ReaderWriterState") { + test("Semigroupal syntax is usable on ReaderWriterState") { val rws = addAndLog(5) *> addAndLog(10) val (log, state, result) = rws.run("context", 0).value @@ -302,7 +302,7 @@ class ReaderWriterStateTTests extends CatsSuite { } } - implicit val iso = CartesianTests.Isomorphisms + implicit val iso = SemigroupalTests.Isomorphisms .invariant[IndexedReaderWriterStateT[ListWrapper, String, String, Int, String, ?]](IndexedReaderWriterStateT.catsDataFunctorForIRWST(ListWrapper.functor)) { @@ -353,7 +353,7 @@ class ReaderWriterStateTTests extends CatsSuite { } { - implicit val iso = CartesianTests.Isomorphisms.invariant[ReaderWriterStateT[Option, String, String, Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[ReaderWriterStateT[Option, String, String, Int, ?]] implicit val eqEitherTFA: Eq[EitherT[ReaderWriterStateT[Option, String, String, Int, ?], Unit, Int]] = EitherT.catsDataEqForEitherT[ReaderWriterStateT[Option, String, String, Int, ?], Unit, Int] diff --git a/tests/src/test/scala/cats/tests/IndexedStateTTests.scala b/tests/src/test/scala/cats/tests/IndexedStateTTests.scala index 75b2fda60d..04609d4cf8 100644 --- a/tests/src/test/scala/cats/tests/IndexedStateTTests.scala +++ b/tests/src/test/scala/cats/tests/IndexedStateTTests.scala @@ -143,7 +143,7 @@ class IndexedStateTTests extends CatsSuite { } } - test("Cartesian syntax is usable on State") { + test("Semigroupal syntax is usable on State") { val x = add1 *> add1 x.runS(0).value should === (2) } @@ -245,7 +245,7 @@ class IndexedStateTTests extends CatsSuite { } - implicit val iso = CartesianTests.Isomorphisms.invariant[IndexedStateT[ListWrapper, String, Int, ?]](IndexedStateT.catsDataFunctorForIndexedStateT(ListWrapper.monad)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[IndexedStateT[ListWrapper, String, Int, ?]](IndexedStateT.catsDataFunctorForIndexedStateT(ListWrapper.monad)) { // F has a Functor @@ -366,7 +366,7 @@ class IndexedStateTTests extends CatsSuite { } { - implicit val iso = CartesianTests.Isomorphisms.invariant[State[Long, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[State[Long, ?]] checkAll("State[Long, ?]", MonadTests[State[Long, ?]].monad[Int, Int, Int]) checkAll("Monad[State[Long, ?]]", SerializableTests.serializable(Monad[State[Long, ?]])) @@ -374,7 +374,7 @@ class IndexedStateTTests extends CatsSuite { { // F has a MonadError - implicit val iso = CartesianTests.Isomorphisms.invariant[StateT[Option, Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[StateT[Option, Int, ?]] implicit val eqEitherTFA: Eq[EitherT[StateT[Option, Int , ?], Unit, Int]] = EitherT.catsDataEqForEitherT[StateT[Option, Int , ?], Unit, Int] checkAll("StateT[Option, Int, Int]", MonadErrorTests[StateT[Option, Int, ?], Unit].monadError[Int, Int, Int]) diff --git a/tests/src/test/scala/cats/tests/IorTests.scala b/tests/src/test/scala/cats/tests/IorTests.scala index c8e4415e45..f74604b049 100644 --- a/tests/src/test/scala/cats/tests/IorTests.scala +++ b/tests/src/test/scala/cats/tests/IorTests.scala @@ -2,17 +2,17 @@ package cats package tests import cats.kernel.laws.discipline.{SemigroupLawTests} -import cats.laws.discipline.{BifunctorTests, CartesianTests, MonadErrorTests, SerializableTests, TraverseTests} +import cats.laws.discipline.{BifunctorTests, SemigroupalTests, MonadErrorTests, SerializableTests, TraverseTests} import cats.data.{Ior, NonEmptyList, EitherT} import cats.laws.discipline.arbitrary._ import org.scalacheck.Arbitrary._ class IorTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Ior[String, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Ior[String, ?]] - checkAll("Ior[String, Int]", CartesianTests[Ior[String, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[String Ior ?]]", SerializableTests.serializable(Cartesian[String Ior ?])) + checkAll("Ior[String, Int]", SemigroupalTests[Ior[String, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[String Ior ?]]", SerializableTests.serializable(Semigroupal[String Ior ?])) implicit val eq0 = EitherT.catsDataEqForEitherT[Ior[String, ?], String, Int] diff --git a/tests/src/test/scala/cats/tests/KernelContravariantTests.scala b/tests/src/test/scala/cats/tests/KernelContravariantTests.scala index fa43e2db08..0aefd2e63f 100644 --- a/tests/src/test/scala/cats/tests/KernelContravariantTests.scala +++ b/tests/src/test/scala/cats/tests/KernelContravariantTests.scala @@ -9,26 +9,26 @@ import cats.laws.discipline.eq._ class KernelContravariantTests extends CatsSuite { Invariant[Eq] Contravariant[Eq] - Cartesian[Eq] - ContravariantCartesian[Eq] + Semigroupal[Eq] + ContravariantSemigroupal[Eq] checkAll("Contravariant[Eq]", ContravariantTests[Eq].contravariant[Int, Int, Int]) - checkAll("Cartesian[Eq]", CartesianTests[Eq].cartesian[Int, Int, Int]) + checkAll("Semigroupal[Eq]", SemigroupalTests[Eq].semigroupal[Int, Int, Int]) checkAll("Contravariant[Eq]", SerializableTests.serializable(Contravariant[Eq])) Invariant[PartialOrder] Contravariant[PartialOrder] - Cartesian[PartialOrder] - ContravariantCartesian[PartialOrder] + Semigroupal[PartialOrder] + ContravariantSemigroupal[PartialOrder] checkAll("Contravariant[PartialOrder]", ContravariantTests[PartialOrder].contravariant[Int, Int, Int]) - checkAll("Cartesian[PartialOrder]", CartesianTests[PartialOrder].cartesian[Int, Int, Int]) + checkAll("Semigroupal[PartialOrder]", SemigroupalTests[PartialOrder].semigroupal[Int, Int, Int]) checkAll("Contravariant[PartialOrder]", SerializableTests.serializable(Contravariant[PartialOrder])) Invariant[Order] Contravariant[Order] - Cartesian[Order] - ContravariantCartesian[Order] + Semigroupal[Order] + ContravariantSemigroupal[Order] checkAll("Contravariant[Order]", ContravariantTests[Order].contravariant[Int, Int, Int]) - checkAll("Cartesian[Order]", CartesianTests[Order].cartesian[Int, Int, Int]) + checkAll("Semigroupal[Order]", SemigroupalTests[Order].semigroupal[Int, Int, Int]) checkAll("Contravariant[Order]", SerializableTests.serializable(Contravariant[Order])) Contravariant[Hash] diff --git a/tests/src/test/scala/cats/tests/KleisliTests.scala b/tests/src/test/scala/cats/tests/KleisliTests.scala index c032a9a425..a61fff6445 100644 --- a/tests/src/test/scala/cats/tests/KleisliTests.scala +++ b/tests/src/test/scala/cats/tests/KleisliTests.scala @@ -21,8 +21,8 @@ class KleisliTests extends CatsSuite { implicit val eitherTEq = EitherT.catsDataEqForEitherT[Kleisli[Option, Int, ?], Unit, Int] implicit val eitherTEq2 = EitherT.catsDataEqForEitherT[Reader[Int, ?], Unit, Int] - implicit val iso = CartesianTests.Isomorphisms.invariant[Kleisli[Option, Int, ?]] - implicit val iso2 = CartesianTests.Isomorphisms.invariant[Reader[Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Kleisli[Option, Int, ?]] + implicit val iso2 = SemigroupalTests.Isomorphisms.invariant[Reader[Int, ?]] { implicit val instance: ApplicativeError[Kleisli[Option, Int, ?], Unit] = Kleisli.catsDataApplicativeErrorForKleisli[Option, Unit, Int](cats.instances.option.catsStdInstancesForOption) @@ -33,8 +33,8 @@ class KleisliTests extends CatsSuite { checkAll("Kleisli[Option, Int, Int] with Unit", MonadErrorTests[Kleisli[Option, Int, ?], Unit].monadError[Int, Int, Int]) checkAll("MonadError[Kleisli[Option, Int, Int], Unit]", SerializableTests.serializable(MonadError[Kleisli[Option, Int, ?], Unit])) - checkAll("Kleisli[Option, Int, Int]", CartesianTests[Kleisli[Option, Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Kleisli[Option, Int, ?]]", SerializableTests.serializable(Cartesian[Kleisli[Option, Int, ?]])) + checkAll("Kleisli[Option, Int, Int]", SemigroupalTests[Kleisli[Option, Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Kleisli[Option, Int, ?]]", SerializableTests.serializable(Semigroupal[Kleisli[Option, Int, ?]])) checkAll("Kleisli[Option, Int, ?]", CommutativeMonadTests[Kleisli[Option, Int, ?]].commutativeMonad[Int, Int, Int]) checkAll("CommutativeMonad[Kleisli[Option, Int, ?]]",SerializableTests.serializable(CommutativeMonad[Kleisli[Option, Int, ?]])) diff --git a/tests/src/test/scala/cats/tests/ListTests.scala b/tests/src/test/scala/cats/tests/ListTests.scala index bb8640a296..2b28f3dbd5 100644 --- a/tests/src/test/scala/cats/tests/ListTests.scala +++ b/tests/src/test/scala/cats/tests/ListTests.scala @@ -2,13 +2,13 @@ package cats package tests import cats.data.NonEmptyList -import cats.laws.discipline.{TraverseTests, CoflatMapTests, AlternativeTests, SerializableTests, CartesianTests} +import cats.laws.discipline.{TraverseTests, CoflatMapTests, AlternativeTests, SerializableTests, SemigroupalTests} import cats.laws.discipline.arbitrary._ class ListTests extends CatsSuite { - checkAll("List[Int]", CartesianTests[List].cartesian[Int, Int, Int]) - checkAll("Cartesian[List]", SerializableTests.serializable(Cartesian[List])) + checkAll("List[Int]", SemigroupalTests[List].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[List]", SerializableTests.serializable(Semigroupal[List])) checkAll("List[Int]", CoflatMapTests[List].coflatMap[Int, Int, Int]) checkAll("CoflatMap[List]", SerializableTests.serializable(CoflatMap[List])) diff --git a/tests/src/test/scala/cats/tests/MapTests.scala b/tests/src/test/scala/cats/tests/MapTests.scala index fb33354c64..b4d403cbd0 100644 --- a/tests/src/test/scala/cats/tests/MapTests.scala +++ b/tests/src/test/scala/cats/tests/MapTests.scala @@ -1,13 +1,13 @@ package cats package tests -import cats.laws.discipline.{TraverseTests, FlatMapTests, SerializableTests, CartesianTests} +import cats.laws.discipline.{TraverseTests, FlatMapTests, SerializableTests, SemigroupalTests} class MapTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Map[Int, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Map[Int, ?]] - checkAll("Map[Int, Int]", CartesianTests[Map[Int, ?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Map[Int, ?]]", SerializableTests.serializable(Cartesian[Map[Int, ?]])) + checkAll("Map[Int, Int]", SemigroupalTests[Map[Int, ?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Map[Int, ?]]", SerializableTests.serializable(Semigroupal[Map[Int, ?]])) checkAll("Map[Int, Int]", FlatMapTests[Map[Int, ?]].flatMap[Int, Int, Int]) checkAll("FlatMap[Map[Int, ?]]", SerializableTests.serializable(FlatMap[Map[Int, ?]])) diff --git a/tests/src/test/scala/cats/tests/MonoidTests.scala b/tests/src/test/scala/cats/tests/MonoidTests.scala index 0fc27453ec..dc14ca85f6 100644 --- a/tests/src/test/scala/cats/tests/MonoidTests.scala +++ b/tests/src/test/scala/cats/tests/MonoidTests.scala @@ -6,7 +6,7 @@ package tests class MonoidTests extends CatsSuite { { Invariant[Monoid] - Cartesian[Monoid] + Semigroupal[Monoid] InvariantMonoidal[Monoid] } @@ -21,7 +21,7 @@ object MonoidTests { def summonInstance(): Unit = { import cats.instances.monoid._ Invariant[Monoid] - Cartesian[Monoid] + Semigroupal[Monoid] InvariantMonoidal[Monoid] () } diff --git a/tests/src/test/scala/cats/tests/NestedTests.scala b/tests/src/test/scala/cats/tests/NestedTests.scala index 1f90d3ec30..3bf0425f75 100644 --- a/tests/src/test/scala/cats/tests/NestedTests.scala +++ b/tests/src/test/scala/cats/tests/NestedTests.scala @@ -5,7 +5,7 @@ import cats.Functor import cats.data._ import cats.laws.discipline._ -import cats.laws.discipline.CartesianTests.Isomorphisms._ +import cats.laws.discipline.SemigroupalTests.Isomorphisms._ import cats.laws.discipline.arbitrary._ import cats.laws.discipline.eq.catsLawsEqForShow diff --git a/tests/src/test/scala/cats/tests/OneAndTests.scala b/tests/src/test/scala/cats/tests/OneAndTests.scala index f3028f861e..2ba70a97b5 100644 --- a/tests/src/test/scala/cats/tests/OneAndTests.scala +++ b/tests/src/test/scala/cats/tests/OneAndTests.scala @@ -8,7 +8,7 @@ import cats.kernel.laws.discipline.{ import cats.instances.stream._ import cats.data.{NonEmptyStream, OneAnd} -import cats.laws.discipline.{ComonadTests, FunctorTests, SemigroupKTests, FoldableTests, MonadTests, SerializableTests, CartesianTests, TraverseTests, NonEmptyTraverseTests, ReducibleTests} +import cats.laws.discipline.{ComonadTests, FunctorTests, SemigroupKTests, FoldableTests, MonadTests, SerializableTests, SemigroupalTests, TraverseTests, NonEmptyTraverseTests, ReducibleTests} import cats.laws.discipline.arbitrary._ class OneAndTests extends CatsSuite { @@ -30,7 +30,7 @@ class OneAndTests extends CatsSuite { checkAll("OneAnd[Stream, Int]", ReducibleTests[OneAnd[Stream, ?]].reducible[Option, Int, Int]) checkAll("Reducible[OneAnd[Stream, ?]]", SerializableTests.serializable(Reducible[OneAnd[Stream, ?]])) - implicit val iso = CartesianTests.Isomorphisms.invariant[OneAnd[ListWrapper, ?]](OneAnd.catsDataFunctorForOneAnd(ListWrapper.functor)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[OneAnd[ListWrapper, ?]](OneAnd.catsDataFunctorForOneAnd(ListWrapper.functor)) // Test instances that have more general constraints { @@ -67,7 +67,7 @@ class OneAndTests extends CatsSuite { implicitly[Comonad[NonEmptyStream]] } - implicit val iso2 = CartesianTests.Isomorphisms.invariant[OneAnd[Stream, ?]] + implicit val iso2 = SemigroupalTests.Isomorphisms.invariant[OneAnd[Stream, ?]] checkAll("NonEmptyStream[Int]", MonadTests[NonEmptyStream].monad[Int, Int, Int]) checkAll("Monad[NonEmptyStream[A]]", SerializableTests.serializable(Monad[NonEmptyStream])) diff --git a/tests/src/test/scala/cats/tests/OptionTTests.scala b/tests/src/test/scala/cats/tests/OptionTTests.scala index abf4db2907..a1acf90cce 100644 --- a/tests/src/test/scala/cats/tests/OptionTTests.scala +++ b/tests/src/test/scala/cats/tests/OptionTTests.scala @@ -13,7 +13,7 @@ import cats.laws.discipline._ import cats.laws.discipline.arbitrary._ class OptionTTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[OptionT[ListWrapper, ?]](OptionT.catsDataFunctorForOptionT(ListWrapper.functor)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[OptionT[ListWrapper, ?]](OptionT.catsDataFunctorForOptionT(ListWrapper.functor)) { implicit val F = ListWrapper.eqv[Option[Int]] diff --git a/tests/src/test/scala/cats/tests/OptionTests.scala b/tests/src/test/scala/cats/tests/OptionTests.scala index b8b15285b8..a9aef3ce54 100644 --- a/tests/src/test/scala/cats/tests/OptionTests.scala +++ b/tests/src/test/scala/cats/tests/OptionTests.scala @@ -5,8 +5,8 @@ import cats.laws.{ApplicativeLaws, CoflatMapLaws, FlatMapLaws, MonadLaws} import cats.laws.discipline._ class OptionTests extends CatsSuite { - checkAll("Option[Int]", CartesianTests[Option].cartesian[Int, Int, Int]) - checkAll("Cartesian[Option]", SerializableTests.serializable(Cartesian[Option])) + checkAll("Option[Int]", SemigroupalTests[Option].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Option]", SerializableTests.serializable(Semigroupal[Option])) checkAll("Option[Int]", CoflatMapTests[Option].coflatMap[Int, Int, Int]) checkAll("CoflatMap[Option]", SerializableTests.serializable(CoflatMap[Option])) diff --git a/tests/src/test/scala/cats/tests/OrderingTests.scala b/tests/src/test/scala/cats/tests/OrderingTests.scala index a397751668..f00d3d6434 100644 --- a/tests/src/test/scala/cats/tests/OrderingTests.scala +++ b/tests/src/test/scala/cats/tests/OrderingTests.scala @@ -10,10 +10,10 @@ class OrderingTests extends CatsSuite { Invariant[Ordering] Contravariant[Ordering] - Cartesian[Ordering] - ContravariantCartesian[Ordering] + Semigroupal[Ordering] + ContravariantSemigroupal[Ordering] checkAll("Contravariant[Ordering]", ContravariantTests[Ordering].contravariant[Int, Int, Int]) - checkAll("Cartesian[Ordering]", CartesianTests[Ordering].cartesian[Int, Int, Int]) + checkAll("Semigroupal[Ordering]", SemigroupalTests[Ordering].semigroupal[Int, Int, Int]) checkAll("Contravariant[Ordering]", SerializableTests.serializable(Contravariant[Ordering])) } diff --git a/tests/src/test/scala/cats/tests/PartialOrderingTests.scala b/tests/src/test/scala/cats/tests/PartialOrderingTests.scala index 1e3f37e6f0..f5d02643b1 100644 --- a/tests/src/test/scala/cats/tests/PartialOrderingTests.scala +++ b/tests/src/test/scala/cats/tests/PartialOrderingTests.scala @@ -10,10 +10,10 @@ class PartialOrderingTests extends CatsSuite { Invariant[PartialOrdering] Contravariant[PartialOrdering] - Cartesian[PartialOrdering] - ContravariantCartesian[PartialOrdering] + Semigroupal[PartialOrdering] + ContravariantSemigroupal[PartialOrdering] checkAll("Contravariant[PartialOrdering]", ContravariantTests[PartialOrdering].contravariant[Int, Int, Int]) - checkAll("Cartesian[PartialOrdering]", CartesianTests[PartialOrdering].cartesian[Int, Int, Int]) + checkAll("Semigroupal[PartialOrdering]", SemigroupalTests[PartialOrdering].semigroupal[Int, Int, Int]) checkAll("Contravariant[PartialOrdering]", SerializableTests.serializable(Contravariant[PartialOrdering])) } diff --git a/tests/src/test/scala/cats/tests/QueueTests.scala b/tests/src/test/scala/cats/tests/QueueTests.scala index 0406d48e84..4963db0435 100644 --- a/tests/src/test/scala/cats/tests/QueueTests.scala +++ b/tests/src/test/scala/cats/tests/QueueTests.scala @@ -3,11 +3,11 @@ package tests import scala.collection.immutable.Queue -import cats.laws.discipline.{CoflatMapTests, MonadTests, AlternativeTests, SerializableTests, TraverseTests, CartesianTests} +import cats.laws.discipline.{CoflatMapTests, MonadTests, AlternativeTests, SerializableTests, TraverseTests, SemigroupalTests} class QueueTests extends CatsSuite { - checkAll("Queue[Int]", CartesianTests[Queue].cartesian[Int, Int, Int]) - checkAll("Cartesian[Queue]", SerializableTests.serializable(Cartesian[Queue])) + checkAll("Queue[Int]", SemigroupalTests[Queue].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Queue]", SerializableTests.serializable(Semigroupal[Queue])) checkAll("Queue[Int]", CoflatMapTests[Queue].coflatMap[Int, Int, Int]) checkAll("CoflatMap[Queue]", SerializableTests.serializable(CoflatMap[Queue])) diff --git a/tests/src/test/scala/cats/tests/SemigroupTests.scala b/tests/src/test/scala/cats/tests/SemigroupTests.scala index 18773ecb4e..1f536b5ae5 100644 --- a/tests/src/test/scala/cats/tests/SemigroupTests.scala +++ b/tests/src/test/scala/cats/tests/SemigroupTests.scala @@ -9,14 +9,14 @@ class SemigroupTests extends FunSuite { { import cats.implicits._ Invariant[Semigroup] - Cartesian[Semigroup] + Semigroupal[Semigroup] InvariantMonoidal[Semigroup] } { import cats.instances.semigroup._ Invariant[Semigroup] - Cartesian[Semigroup] + Semigroupal[Semigroup] InvariantMonoidal[Semigroup] } } diff --git a/tests/src/test/scala/cats/tests/StreamTests.scala b/tests/src/test/scala/cats/tests/StreamTests.scala index 8ea90f21e9..971fde07c8 100644 --- a/tests/src/test/scala/cats/tests/StreamTests.scala +++ b/tests/src/test/scala/cats/tests/StreamTests.scala @@ -1,11 +1,11 @@ package cats package tests -import cats.laws.discipline.{CoflatMapTests, MonadTests, AlternativeTests, SerializableTests, TraverseTests, CartesianTests} +import cats.laws.discipline.{CoflatMapTests, MonadTests, AlternativeTests, SerializableTests, TraverseTests, SemigroupalTests} class StreamTests extends CatsSuite { - checkAll("Stream[Int]", CartesianTests[Stream].cartesian[Int, Int, Int]) - checkAll("Cartesian[Stream]", SerializableTests.serializable(Cartesian[Stream])) + checkAll("Stream[Int]", SemigroupalTests[Stream].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Stream]", SerializableTests.serializable(Semigroupal[Stream])) checkAll("Stream[Int]", CoflatMapTests[Stream].coflatMap[Int, Int, Int]) checkAll("CoflatMap[Stream]", SerializableTests.serializable(CoflatMap[Stream])) diff --git a/tests/src/test/scala/cats/tests/SyntaxTests.scala b/tests/src/test/scala/cats/tests/SyntaxTests.scala index 1d8006f3d8..1bb81c456b 100644 --- a/tests/src/test/scala/cats/tests/SyntaxTests.scala +++ b/tests/src/test/scala/cats/tests/SyntaxTests.scala @@ -201,7 +201,7 @@ object SyntaxTests extends AllInstances with AllSyntax { val fb1: F[B] = fa.as(b) } - def testApply[F[_]: Apply : Cartesian, G[_]: Contravariant : Cartesian, H[_]: Invariant : Cartesian, A, B, C, D, E, Z] = { + def testApply[F[_]: Apply : Semigroupal, G[_]: Contravariant : Semigroupal, H[_]: Invariant : Semigroupal, A, B, C, D, E, Z] = { val tfabc = mock[(F[A], F[B], F[C])] val fa = mock[F[A]] val fb = mock[F[B]] diff --git a/tests/src/test/scala/cats/tests/TryTests.scala b/tests/src/test/scala/cats/tests/TryTests.scala index b4ff873382..c3b2772025 100644 --- a/tests/src/test/scala/cats/tests/TryTests.scala +++ b/tests/src/test/scala/cats/tests/TryTests.scala @@ -14,8 +14,8 @@ import scala.util.{Success, Try} class TryTests extends CatsSuite { implicit val eqThrow: Eq[Throwable] = Eq.allEqual - checkAll("Try[Int]", CartesianTests[Try].cartesian[Int, Int, Int]) - checkAll("Cartesian[Try]", SerializableTests.serializable(Cartesian[Try])) + checkAll("Try[Int]", SemigroupalTests[Try].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Try]", SerializableTests.serializable(Semigroupal[Try])) checkAll("Try[Int]", CoflatMapTests[Try].coflatMap[Int, Int, Int]) checkAll("CoflatMap[Try]", SerializableTests.serializable(CoflatMap[Try])) diff --git a/tests/src/test/scala/cats/tests/Tuple2KTests.scala b/tests/src/test/scala/cats/tests/Tuple2KTests.scala index d207c66f57..8dd04b8b3b 100644 --- a/tests/src/test/scala/cats/tests/Tuple2KTests.scala +++ b/tests/src/test/scala/cats/tests/Tuple2KTests.scala @@ -13,9 +13,9 @@ import cats.kernel.laws.discipline.{ } class Tuple2KTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Tuple2K[Option, List, ?]] - checkAll("Tuple2K[Option, List, Int]", CartesianTests[λ[α => Tuple2K[Option, List, α]]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Tuple2K[Option, List, Int]]", SerializableTests.serializable(Cartesian[λ[α => Tuple2K[Option, List, α]]])) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Tuple2K[Option, List, ?]] + checkAll("Tuple2K[Option, List, Int]", SemigroupalTests[λ[α => Tuple2K[Option, List, α]]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Tuple2K[Option, List, Int]]", SerializableTests.serializable(Semigroupal[λ[α => Tuple2K[Option, List, α]]])) checkAll("Tuple2K[Option, List, Int]", AlternativeTests[λ[α => Tuple2K[Option, List, α]]].alternative[Int, Int, Int]) checkAll("Alternative[Tuple2K[Option, List, Int]]", SerializableTests.serializable(Alternative[λ[α => Tuple2K[Option, List, α]]])) @@ -39,7 +39,7 @@ class Tuple2KTests extends CatsSuite { { implicit val apply = ListWrapper.applyInstance - implicit val iso = CartesianTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] checkAll("Tuple2K[ListWrapper, ListWrapper, ?]", ApplyTests[Tuple2K[ListWrapper, ListWrapper, ?]].apply[Int, Int, Int]) checkAll("Apply[Tuple2K[ListWrapper, ListWrapper, ?]]", SerializableTests.serializable(Apply[Tuple2K[ListWrapper, ListWrapper, ?]])) } @@ -52,7 +52,7 @@ class Tuple2KTests extends CatsSuite { { implicit val monad = ListWrapper.monad - implicit val iso = CartesianTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] checkAll("Tuple2K[ListWrapper, ListWrapper, ?]", MonadTests[Tuple2K[ListWrapper, ListWrapper, ?]].monad[Int, Int, Int]) checkAll("Monad[Tuple2K[ListWrapper, ListWrapper, ?]]", SerializableTests.serializable(Monad[Tuple2K[ListWrapper, ListWrapper, ?]])) } @@ -71,7 +71,7 @@ class Tuple2KTests extends CatsSuite { { implicit val alternative = ListWrapper.alternative - implicit val iso = CartesianTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Tuple2K[ListWrapper, ListWrapper, ?]] checkAll("Tuple2K[ListWrapper, ListWrapper, ?]", AlternativeTests[Tuple2K[ListWrapper, ListWrapper, ?]].alternative[Int, Int, Int]) checkAll("Alternative[Tuple2K[ListWrapper, ListWrapper, ?]]", SerializableTests.serializable(Alternative[Tuple2K[ListWrapper, ListWrapper, ?]])) } diff --git a/tests/src/test/scala/cats/tests/TupleTests.scala b/tests/src/test/scala/cats/tests/TupleTests.scala index 363776e0d5..edf5651323 100644 --- a/tests/src/test/scala/cats/tests/TupleTests.scala +++ b/tests/src/test/scala/cats/tests/TupleTests.scala @@ -8,8 +8,8 @@ import cats.laws.discipline.arbitrary._ class TupleTests extends CatsSuite { - implicit val iso1 = CartesianTests.Isomorphisms.invariant[(NonEmptyList[Int], ?)] - implicit val iso2 = CartesianTests.Isomorphisms.invariant[(String, ?)] + implicit val iso1 = SemigroupalTests.Isomorphisms.invariant[(NonEmptyList[Int], ?)] + implicit val iso2 = SemigroupalTests.Isomorphisms.invariant[(String, ?)] checkAll("Tuple2", BitraverseTests[Tuple2].bitraverse[Option, Int, Int, Int, String, String, String]) checkAll("Bitraverse[Tuple2]", SerializableTests.serializable(Bitraverse[Tuple2])) @@ -30,8 +30,8 @@ class TupleTests extends CatsSuite { checkAll("Tuple2[String, Int]", ReducibleTests[(String, ?)].reducible[Option, Int, Int]) checkAll("Reducible[(String, ?)]", SerializableTests.serializable(Reducible[(String, ?)])) - test("Cartesian composition") { - val cart = ContravariantCartesian[Eq].composeFunctor[(Int, ?)] + test("Semigroupal composition") { + val cart = ContravariantSemigroupal[Eq].composeFunctor[(Int, ?)] val eq = cart.product(Eq[(Int, String)], Eq[(Int, Int)]) forAll { (a: (Int, (String, Int)), b: (Int, (String, Int))) => (a == b) should === (eq.eqv(a, b)) diff --git a/tests/src/test/scala/cats/tests/ValidatedTests.scala b/tests/src/test/scala/cats/tests/ValidatedTests.scala index 8a10682a1f..5c2e8a80a3 100644 --- a/tests/src/test/scala/cats/tests/ValidatedTests.scala +++ b/tests/src/test/scala/cats/tests/ValidatedTests.scala @@ -18,9 +18,9 @@ import cats.kernel.laws.discipline.{ import scala.util.Try class ValidatedTests extends CatsSuite { - implicit val iso = CartesianTests.Isomorphisms.invariant[Validated[String, ?]] - checkAll("Validated[String, Int]", CartesianTests[Validated[String,?]].cartesian[Int, Int, Int]) - checkAll("Cartesian[Validated[String,?]]", SerializableTests.serializable(Cartesian[Validated[String,?]])) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[Validated[String, ?]] + checkAll("Validated[String, Int]", SemigroupalTests[Validated[String,?]].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Validated[String,?]]", SerializableTests.serializable(Semigroupal[Validated[String,?]])) checkAll("Validated[?, ?]", BitraverseTests[Validated].bitraverse[Option, Int, Int, Int, String, String, String]) checkAll("Bitraverse[Validated]", SerializableTests.serializable(Bitraverse[Validated])) diff --git a/tests/src/test/scala/cats/tests/VectorTests.scala b/tests/src/test/scala/cats/tests/VectorTests.scala index d1251f9414..ff86fea92b 100644 --- a/tests/src/test/scala/cats/tests/VectorTests.scala +++ b/tests/src/test/scala/cats/tests/VectorTests.scala @@ -2,12 +2,12 @@ package cats package tests import cats.data.NonEmptyVector -import cats.laws.discipline.{AlternativeTests, CoflatMapTests, SerializableTests, TraverseTests, CartesianTests} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, SerializableTests, TraverseTests, SemigroupalTests} import cats.laws.discipline.arbitrary._ class VectorTests extends CatsSuite { - checkAll("Vector[Int]", CartesianTests[Vector].cartesian[Int, Int, Int]) - checkAll("Cartesian[Vector]", SerializableTests.serializable(Cartesian[Vector])) + checkAll("Vector[Int]", SemigroupalTests[Vector].semigroupal[Int, Int, Int]) + checkAll("Semigroupal[Vector]", SerializableTests.serializable(Semigroupal[Vector])) checkAll("Vector[Int]", CoflatMapTests[Vector].coflatMap[Int, Int, Int]) checkAll("CoflatMap[Vector]", SerializableTests.serializable(CoflatMap[Vector])) diff --git a/tests/src/test/scala/cats/tests/WordCountTest.scala b/tests/src/test/scala/cats/tests/WordCountTest.scala index 065f0eaee1..68831cc378 100644 --- a/tests/src/test/scala/cats/tests/WordCountTest.scala +++ b/tests/src/test/scala/cats/tests/WordCountTest.scala @@ -12,7 +12,7 @@ class WordCountTest extends CatsSuite { test("wordcount") { import cats.data.State.{ get, set } val text = "Faith, I must leave thee, love, and shortly too.\nMy operant powers their functions leave to do.\n".toList - // A type alias to treat Int as cartesian applicative + // A type alias to treat Int as semigroupal applicative type Count[A] = Const[Int, A] // Tye type parameter to Count is ceremonial, so hardcode it to Unit def liftInt(i: Int): Count[Unit] = Const(i) diff --git a/tests/src/test/scala/cats/tests/WriterTTests.scala b/tests/src/test/scala/cats/tests/WriterTTests.scala index 321e8d8aed..fb4d1d49fd 100644 --- a/tests/src/test/scala/cats/tests/WriterTTests.scala +++ b/tests/src/test/scala/cats/tests/WriterTTests.scala @@ -132,7 +132,7 @@ class WriterTTests extends CatsSuite { checkAll("Bifunctor[WriterT[ListWrapper, ?, ?]]", SerializableTests.serializable(Bifunctor[WriterT[ListWrapper, ?, ?]])) } - implicit val iso = CartesianTests.Isomorphisms.invariant[WriterT[ListWrapper, ListWrapper[Int], ?]](WriterT.catsDataCoflatMapForWriterT(ListWrapper.functor)) + implicit val iso = SemigroupalTests.Isomorphisms.invariant[WriterT[ListWrapper, ListWrapper[Int], ?]](WriterT.catsDataCoflatMapForWriterT(ListWrapper.functor)) // We have varying instances available depending on `F` and `L`. // We also battle some inference issues with `Id`. @@ -317,7 +317,7 @@ class WriterTTests extends CatsSuite { // F has an Applicative and L has a Monoid implicit val L: Monoid[ListWrapper[Int]] = ListWrapper.monoid[Int] implicit val app = WriterT.catsDataApplicativeForWriterT[Validated[String, ?], ListWrapper[Int]] - implicit val iso = CartesianTests.Isomorphisms.invariant[WriterT[Validated[String, ?], ListWrapper[Int], ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[WriterT[Validated[String, ?], ListWrapper[Int], ?]] implicit def eq1[A:Eq]: Eq[WriterT[Validated[String, ?], ListWrapper[Int], A]] = WriterT.catsDataEqForWriterT[Validated[String, ?], ListWrapper[Int], A] implicit val eq2: Eq[EitherT[WriterT[Validated[String, ?], ListWrapper[Int], ?], String, Int]] = @@ -335,7 +335,7 @@ class WriterTTests extends CatsSuite { // F has an ApplicativeError and L has a Monoid implicit val L: Monoid[ListWrapper[Int]] = ListWrapper.monoid[Int] implicit val appErr = WriterT.catsDataApplicativeErrorForWriterT[Validated[String, ?], ListWrapper[Int], String] - implicit val iso = CartesianTests.Isomorphisms.invariant[WriterT[Validated[String, ?], ListWrapper[Int], ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[WriterT[Validated[String, ?], ListWrapper[Int], ?]] checkAll("WriterT[Validated[String, ?], ListWrapper[Int], ?]", ApplicativeErrorTests[WriterT[Validated[String, ?], ListWrapper[Int], ?], String].applicativeError[Int, Int, Int]) checkAll("ApplicativeError[WriterT[Validated[String, ?], ListWrapper[Int], ?], Unit]", SerializableTests.serializable(ApplicativeError[WriterT[Validated[String, ?], ListWrapper[Int], ?], String])) } @@ -343,7 +343,7 @@ class WriterTTests extends CatsSuite { { // F has a MonadError and L has a Monoid implicit val L: Monoid[ListWrapper[Int]] = ListWrapper.monoid[Int] - implicit val iso = CartesianTests.Isomorphisms.invariant[WriterT[Option, ListWrapper[Int], ?]] + implicit val iso = SemigroupalTests.Isomorphisms.invariant[WriterT[Option, ListWrapper[Int], ?]] implicit val eq0: Eq[EitherT[WriterT[Option, ListWrapper[Int], ?], Unit, Int]] = EitherT.catsDataEqForEitherT[WriterT[Option, ListWrapper[Int], ?], Unit, Int]