From dc44c3b2d60e92eb7df6162a9a3840a1eb5609e6 Mon Sep 17 00:00:00 2001 From: Filippo Mariotti Date: Mon, 7 Oct 2019 21:52:48 +0100 Subject: [PATCH] Issue 3059: Move Parallel instances into instance packages for the type constructors they characterize (#3099) * Moved instances from parallel. Added some compilation tests * Removed unneeded matchers * Changed deprecation version --- .travis.yml | 2 +- ...calaVersionSpecificParallelInstances.scala | 66 +++------------ .../scala-2.12/cats/instances/stream.scala | 14 ++++ ...calaVersionSpecificParallelInstances.scala | 82 ++++--------------- .../scala-2.13+/cats/instances/lazyList.scala | 19 ++++- .../scala-2.13+/cats/instances/stream.scala | 18 +++- .../main/scala/cats/instances/either.scala | 17 ++++ core/src/main/scala/cats/instances/list.scala | 15 ++++ .../main/scala/cats/instances/vector.scala | 15 ++++ .../cats/tests/LazyListSuite.scala | 22 ++--- .../cats/tests/ScalaVersionSpecific.scala | 6 +- .../test/scala/cats/tests/EitherSuite.scala | 13 +++ .../src/test/scala/cats/tests/ListSuite.scala | 11 +++ .../test/scala/cats/tests/ParallelSuite.scala | 1 - .../test/scala/cats/tests/StreamSuite.scala | 11 +++ .../test/scala/cats/tests/VectorSuite.scala | 11 +++ 16 files changed, 184 insertions(+), 139 deletions(-) diff --git a/.travis.yml b/.travis.yml index 92e6f82710..197533c80b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ jdk: - openjdk8 -scala_version_212: &scala_version_212 2.12.9 +scala_version_212: &scala_version_212 2.12.10 scala_version_213: &scala_version_213 2.13.0 before_install: diff --git a/core/src/main/scala-2.12/cats/instances/ScalaVersionSpecificParallelInstances.scala b/core/src/main/scala-2.12/cats/instances/ScalaVersionSpecificParallelInstances.scala index 55ab7e7de3..e43b11f7c1 100644 --- a/core/src/main/scala-2.12/cats/instances/ScalaVersionSpecificParallelInstances.scala +++ b/core/src/main/scala-2.12/cats/instances/ScalaVersionSpecificParallelInstances.scala @@ -3,70 +3,30 @@ package instances import cats.data._ import cats.kernel.Semigroup -import cats.syntax.either._ -import cats.{~>, Applicative, Apply, FlatMap, Monad, NonEmptyParallel, Parallel} +import cats.{NonEmptyParallel, Parallel} trait ParallelInstances extends ParallelInstances1 { - implicit def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] = - new Parallel[Either[E, *]] { - type F[x] = Validated[E, x] - def applicative: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated - def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither - - def sequential: Validated[E, *] ~> Either[E, *] = - λ[Validated[E, *] ~> Either[E, *]](_.toEither) - - def parallel: Either[E, *] ~> Validated[E, *] = - λ[Either[E, *] ~> Validated[E, *]](_.toValidated) - } + @deprecated("Use cats.instances.either.catsParallelForEitherAndValidated", "2.1.0") + def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] = + cats.instances.either.catsParallelForEitherAndValidated[E] @deprecated("Use OptionT.catsDataParallelForOptionT", "2.0.0") def catsParallelForOptionTNestedOption[M[_]]( implicit P: Parallel[M] ): Parallel.Aux[OptionT[M, *], Nested[P.F, Option, *]] = OptionT.catsDataParallelForOptionT[M] - implicit def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] = - new NonEmptyParallel[List] { - type F[x] = ZipList[x] - - def flatMap: FlatMap[List] = cats.instances.list.catsStdInstancesForList - def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList - - def sequential: ZipList ~> List = - λ[ZipList ~> List](_.value) - - def parallel: List ~> ZipList = - λ[List ~> ZipList](v => new ZipList(v)) - } - - implicit def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] = - new NonEmptyParallel[Vector] { - type F[x] = ZipVector[x] - - def flatMap: FlatMap[Vector] = cats.instances.vector.catsStdInstancesForVector - def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector - - def sequential: ZipVector ~> Vector = - λ[ZipVector ~> Vector](_.value) - - def parallel: Vector ~> ZipVector = - λ[Vector ~> ZipVector](v => new ZipVector(v)) - } - - implicit def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] = - new Parallel[Stream] { - type F[x] = ZipStream[x] - - def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream - def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream + @deprecated("Use cats.instances.list.catsStdNonEmptyParallelForListZipList", "2.1.0") + def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] = + cats.instances.list.catsStdNonEmptyParallelForListZipList - def sequential: ZipStream ~> Stream = - λ[ZipStream ~> Stream](_.value) + @deprecated("Use cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector", "2.1.0") + def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] = + cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector - def parallel: Stream ~> ZipStream = - λ[Stream ~> ZipStream](v => new ZipStream(v)) - } + @deprecated("Use cats.instances.stream.catsStdParallelForStreamZipStream", "2.1.0") + def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] = + cats.instances.stream.catsStdParallelForStreamZipStream @deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0") def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup]( diff --git a/core/src/main/scala-2.12/cats/instances/stream.scala b/core/src/main/scala-2.12/cats/instances/stream.scala index de0fcbbf84..67d4db6e19 100644 --- a/core/src/main/scala-2.12/cats/instances/stream.scala +++ b/core/src/main/scala-2.12/cats/instances/stream.scala @@ -1,6 +1,7 @@ package cats package instances +import cats.data.ZipStream import cats.syntax.show._ import scala.annotation.tailrec @@ -157,6 +158,19 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { def show(fa: Stream[A]): String = if (fa.isEmpty) "Stream()" else s"Stream(${fa.head.show}, ?)" } + implicit def catsStdParallelForStreamZipStream: Parallel.Aux[Stream, ZipStream] = + new Parallel[Stream] { + type F[x] = ZipStream[x] + + def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream + def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream + + def sequential: ZipStream ~> Stream = + λ[ZipStream ~> Stream](_.value) + + def parallel: Stream ~> ZipStream = + λ[Stream ~> ZipStream](v => new ZipStream(v)) + } } private[instances] trait StreamInstancesBinCompat0 { diff --git a/core/src/main/scala-2.13+/cats/instances/ScalaVersionSpecificParallelInstances.scala b/core/src/main/scala-2.13+/cats/instances/ScalaVersionSpecificParallelInstances.scala index ae37f968fe..f3c16fcaa0 100644 --- a/core/src/main/scala-2.13+/cats/instances/ScalaVersionSpecificParallelInstances.scala +++ b/core/src/main/scala-2.13+/cats/instances/ScalaVersionSpecificParallelInstances.scala @@ -3,85 +3,35 @@ package instances import cats.data._ import cats.kernel.Semigroup -import cats.syntax.either._ -import cats.{~>, Applicative, Apply, FlatMap, Monad, NonEmptyParallel, Parallel} +import cats.data.ZipLazyList +import cats.{NonEmptyParallel, Parallel} trait ParallelInstances extends ParallelInstances1 { - implicit def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] = - new Parallel[Either[E, *]] { - type F[x] = Validated[E, x] - def applicative: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated - def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither - - def sequential: Validated[E, *] ~> Either[E, *] = - λ[Validated[E, *] ~> Either[E, *]](_.toEither) - - def parallel: Either[E, *] ~> Validated[E, *] = - λ[Either[E, *] ~> Validated[E, *]](_.toValidated) - } + @deprecated("Use cats.instances.either.catsParallelForEitherAndValidated", "2.1.0") + def catsParallelForEitherValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] = + cats.instances.either.catsParallelForEitherAndValidated[E] @deprecated("Use OptionT.catsDataParallelForOptionT", "2.0.0") def catsParallelForOptionTNestedOption[M[_]]( implicit P: Parallel[M] ): Parallel.Aux[OptionT[M, *], Nested[P.F, Option, *]] = OptionT.catsDataParallelForOptionT[M] - implicit def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] = - new NonEmptyParallel[List] { - type F[x] = ZipList[x] - - def flatMap: FlatMap[List] = cats.instances.list.catsStdInstancesForList - def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList - - def sequential: ZipList ~> List = - λ[ZipList ~> List](_.value) - - def parallel: List ~> ZipList = - λ[List ~> ZipList](v => new ZipList(v)) - } - - implicit def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] = - new NonEmptyParallel[Vector] { - type F[x] = ZipVector[x] - - def flatMap: FlatMap[Vector] = cats.instances.vector.catsStdInstancesForVector - def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector + @deprecated("Use cats.instances.list.catsStdNonEmptyParallelForListZipList", "2.1.0") + def catsStdNonEmptyParallelForZipList: NonEmptyParallel.Aux[List, ZipList] = + cats.instances.list.catsStdNonEmptyParallelForListZipList - def sequential: ZipVector ~> Vector = - λ[ZipVector ~> Vector](_.value) - - def parallel: Vector ~> ZipVector = - λ[Vector ~> ZipVector](v => new ZipVector(v)) - } + @deprecated("Use cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector", "2.1.0") + def catsStdNonEmptyParallelForZipVector: NonEmptyParallel.Aux[Vector, ZipVector] = + cats.instances.vector.catsStdNonEmptyParallelForVectorZipVector @deprecated("Use catsStdParallelForZipLazyList", "2.0.0-RC2") - implicit def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] = - new Parallel[Stream] { - type F[x] = ZipStream[x] - - def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream - def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream - - def sequential: ZipStream ~> Stream = - λ[ZipStream ~> Stream](_.value) - - def parallel: Stream ~> ZipStream = - λ[Stream ~> ZipStream](v => new ZipStream(v)) - } - - implicit def catsStdParallelForZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] = - new Parallel[LazyList] { - type F[x] = ZipLazyList[x] - - def monad: Monad[LazyList] = cats.instances.lazyList.catsStdInstancesForLazyList - def applicative: Applicative[ZipLazyList] = ZipLazyList.catsDataAlternativeForZipLazyList - - def sequential: ZipLazyList ~> LazyList = - λ[ZipLazyList ~> LazyList](_.value) + def catsStdParallelForZipStream: Parallel.Aux[Stream, ZipStream] = + cats.instances.stream.catsStdParallelForStreamZipStream - def parallel: LazyList ~> ZipLazyList = - λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v)) - } + @deprecated("Use cats.instances.lazyList.catsStdParallelForLazyListZipLazyList", "2.1.0") + def catsStdParallelForZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] = + cats.instances.lazyList.catsStdParallelForLazyListZipLazyList[A] @deprecated("Use EitherT.catsDataParallelForEitherTWithParallelEffect", "2.0.0") def catsParallelForEitherTNestedParallelValidated[M[_], E: Semigroup]( diff --git a/core/src/main/scala-2.13+/cats/instances/lazyList.scala b/core/src/main/scala-2.13+/cats/instances/lazyList.scala index 1d55cb8c21..6c4e083540 100644 --- a/core/src/main/scala-2.13+/cats/instances/lazyList.scala +++ b/core/src/main/scala-2.13+/cats/instances/lazyList.scala @@ -1,13 +1,14 @@ package cats package instances + import cats.kernel import cats.syntax.show._ +import cats.data.ZipLazyList import scala.annotation.tailrec trait LazyListInstances extends cats.kernel.instances.LazyListInstances { - implicit val catsStdInstancesForLazyList - : Traverse[LazyList] with Alternative[LazyList] with Monad[LazyList] with CoflatMap[LazyList] = + implicit val catsStdInstancesForLazyList: Traverse[LazyList] with Alternative[LazyList] with Monad[LazyList] with CoflatMap[LazyList] = new Traverse[LazyList] with Alternative[LazyList] with Monad[LazyList] with CoflatMap[LazyList] { def empty[A]: LazyList[A] = LazyList.empty @@ -155,4 +156,18 @@ trait LazyListInstances extends cats.kernel.instances.LazyListInstances { .value } + + implicit def catsStdParallelForLazyListZipLazyList[A]: Parallel.Aux[LazyList, ZipLazyList] = + new Parallel[LazyList] { + type F[x] = ZipLazyList[x] + + def monad: Monad[LazyList] = cats.instances.lazyList.catsStdInstancesForLazyList + def applicative: Applicative[ZipLazyList] = ZipLazyList.catsDataAlternativeForZipLazyList + + def sequential: ZipLazyList ~> LazyList = + λ[ZipLazyList ~> LazyList](_.value) + + def parallel: LazyList ~> ZipLazyList = + λ[LazyList ~> ZipLazyList](v => new ZipLazyList(v)) + } } diff --git a/core/src/main/scala-2.13+/cats/instances/stream.scala b/core/src/main/scala-2.13+/cats/instances/stream.scala index 68844aa794..df1c6feae5 100644 --- a/core/src/main/scala-2.13+/cats/instances/stream.scala +++ b/core/src/main/scala-2.13+/cats/instances/stream.scala @@ -1,6 +1,7 @@ package cats package instances +import cats.data.ZipStream import cats.syntax.show._ import scala.annotation.tailrec @@ -8,8 +9,7 @@ import scala.annotation.tailrec trait StreamInstances extends cats.kernel.instances.StreamInstances { @deprecated("Use cats.instances.lazyList", "2.0.0-RC2") - implicit val catsStdInstancesForStream - : Traverse[Stream] with Alternative[Stream] with Monad[Stream] with CoflatMap[Stream] = + implicit val catsStdInstancesForStream: Traverse[Stream] with Alternative[Stream] with Monad[Stream] with CoflatMap[Stream] = new Traverse[Stream] with Alternative[Stream] with Monad[Stream] with CoflatMap[Stream] { def empty[A]: Stream[A] = Stream.Empty @@ -159,6 +159,20 @@ trait StreamInstances extends cats.kernel.instances.StreamInstances { def show(fa: Stream[A]): String = if (fa.isEmpty) "Stream()" else s"Stream(${fa.head.show}, ?)" } + @deprecated("Use catsStdParallelForZipLazyList", "2.0.0-RC2") + implicit val catsStdParallelForStreamZipStream: Parallel.Aux[Stream, ZipStream] = + new Parallel[Stream] { + type F[x] = ZipStream[x] + + def monad: Monad[Stream] = cats.instances.stream.catsStdInstancesForStream + def applicative: Applicative[ZipStream] = ZipStream.catsDataAlternativeForZipStream + + def sequential: ZipStream ~> Stream = + λ[ZipStream ~> Stream](_.value) + + def parallel: Stream ~> ZipStream = + λ[Stream ~> ZipStream](v => new ZipStream(v)) + } } private[instances] trait StreamInstancesBinCompat0 { diff --git a/core/src/main/scala/cats/instances/either.scala b/core/src/main/scala/cats/instances/either.scala index 572b5df3c8..ff2025a146 100644 --- a/core/src/main/scala/cats/instances/either.scala +++ b/core/src/main/scala/cats/instances/either.scala @@ -1,8 +1,11 @@ package cats package instances +import cats.data.Validated +import cats.kernel.Semigroup import cats.syntax.EitherUtil import cats.syntax.either._ + import scala.annotation.tailrec trait EitherInstances extends cats.kernel.instances.EitherInstances { @@ -158,4 +161,18 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances { case Right(b) => "Right(" + B.show(b) + ")" } } + + implicit def catsParallelForEitherAndValidated[E: Semigroup]: Parallel.Aux[Either[E, *], Validated[E, *]] = + new Parallel[Either[E, *]] { + type F[x] = Validated[E, x] + + def applicative: Applicative[Validated[E, *]] = Validated.catsDataApplicativeErrorForValidated + def monad: Monad[Either[E, *]] = cats.instances.either.catsStdInstancesForEither + + def sequential: Validated[E, *] ~> Either[E, *] = + λ[Validated[E, *] ~> Either[E, *]](_.toEither) + + def parallel: Either[E, *] ~> Validated[E, *] = + λ[Either[E, *] ~> Validated[E, *]](_.toValidated) + } } diff --git a/core/src/main/scala/cats/instances/list.scala b/core/src/main/scala/cats/instances/list.scala index 975fa14519..d93cadfafe 100644 --- a/core/src/main/scala/cats/instances/list.scala +++ b/core/src/main/scala/cats/instances/list.scala @@ -1,6 +1,7 @@ package cats package instances +import cats.data.ZipList import cats.syntax.show._ import scala.annotation.tailrec @@ -150,6 +151,20 @@ trait ListInstances extends cats.kernel.instances.ListInstances { def show(fa: List[A]): String = fa.iterator.map(_.show).mkString("List(", ", ", ")") } + + implicit def catsStdNonEmptyParallelForListZipList: NonEmptyParallel.Aux[List, ZipList] = + new NonEmptyParallel[List] { + type F[x] = ZipList[x] + + def flatMap: FlatMap[List] = cats.instances.list.catsStdInstancesForList + def apply: Apply[ZipList] = ZipList.catsDataCommutativeApplyForZipList + + def sequential: ZipList ~> List = + λ[ZipList ~> List](_.value) + + def parallel: List ~> ZipList = + λ[List ~> ZipList](v => new ZipList(v)) + } } private[instances] trait ListInstancesBinCompat0 { diff --git a/core/src/main/scala/cats/instances/vector.scala b/core/src/main/scala/cats/instances/vector.scala index 5c27e6f4b9..107efceca8 100644 --- a/core/src/main/scala/cats/instances/vector.scala +++ b/core/src/main/scala/cats/instances/vector.scala @@ -1,6 +1,7 @@ package cats package instances +import cats.data.ZipVector import cats.syntax.show._ import scala.annotation.tailrec @@ -120,6 +121,20 @@ trait VectorInstances extends cats.kernel.instances.VectorInstances { def show(fa: Vector[A]): String = fa.iterator.map(_.show).mkString("Vector(", ", ", ")") } + + implicit def catsStdNonEmptyParallelForVectorZipVector: NonEmptyParallel.Aux[Vector, ZipVector] = + new NonEmptyParallel[Vector] { + type F[x] = ZipVector[x] + + def flatMap: FlatMap[Vector] = cats.instances.vector.catsStdInstancesForVector + def apply: Apply[ZipVector] = ZipVector.catsDataCommutativeApplyForZipVector + + def sequential: ZipVector ~> Vector = + λ[ZipVector ~> Vector](_.value) + + def parallel: Vector ~> ZipVector = + λ[Vector ~> ZipVector](v => new ZipVector(v)) + } } private[instances] trait VectorInstancesBinCompat0 { diff --git a/tests/src/test/scala-2.13+/cats/tests/LazyListSuite.scala b/tests/src/test/scala-2.13+/cats/tests/LazyListSuite.scala index 5392187a2c..171f89a34a 100644 --- a/tests/src/test/scala-2.13+/cats/tests/LazyListSuite.scala +++ b/tests/src/test/scala-2.13+/cats/tests/LazyListSuite.scala @@ -1,18 +1,10 @@ package cats package tests -import cats.laws.discipline.{ - AlternativeTests, - CoflatMapTests, - CommutativeApplyTests, - MonadTests, - SemigroupalTests, - SerializableTests, - TraverseFilterTests, - TraverseTests -} +import cats.laws.discipline.{AlternativeTests, CoflatMapTests, CommutativeApplyTests, MonadTests, SemigroupalTests, SerializableTests, TraverseFilterTests, TraverseTests} import cats.data.ZipLazyList import cats.laws.discipline.arbitrary._ +import org.scalatest.funsuite.AnyFunSuiteLike class LazyListSuite extends CatsSuite { checkAll("LazyList[Int]", SemigroupalTests[LazyList].semigroupal[Int, Int, Int]) @@ -59,3 +51,13 @@ class LazyListSuite extends CatsSuite { } } + +final class LazyListInstancesSuite extends AnyFunSuiteLike { + + test("parallel instance in cats.instances.lazyList") { + import cats.instances.lazyList._ + import cats.syntax.parallel._ + + (LazyList(1, 2, 3), LazyList("A", "B", "C")).parTupled + } +} diff --git a/tests/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala b/tests/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala index 43c3230dd9..76af75af33 100644 --- a/tests/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala +++ b/tests/src/test/scala-2.13+/cats/tests/ScalaVersionSpecific.scala @@ -123,11 +123,9 @@ trait ScalaVersionSpecificParallelSuite { self: ParallelSuite => } // Can't test Parallel here, as Applicative[ZipLazyList].pure doesn't terminate - checkAll("Parallel[LazyList]", - NonEmptyParallelTests[LazyList].nonEmptyParallel[Int, String]) + checkAll("Parallel[LazyList]", NonEmptyParallelTests[LazyList].nonEmptyParallel[Int, String]) - checkAll("Parallel[NonEmptyLazyList]", - ParallelTests[NonEmptyLazyList].parallel[Int, String]) + checkAll("Parallel[NonEmptyLazyList]", ParallelTests[NonEmptyLazyList].parallel[Int, String]) } trait ScalaVersionSpecificRegressionSuite { self: RegressionSuite => diff --git a/tests/src/test/scala/cats/tests/EitherSuite.scala b/tests/src/test/scala/cats/tests/EitherSuite.scala index 7dff18ad7e..3544434b71 100644 --- a/tests/src/test/scala/cats/tests/EitherSuite.scala +++ b/tests/src/test/scala/cats/tests/EitherSuite.scala @@ -4,6 +4,8 @@ package tests import cats.data.{EitherT, NonEmptyChain, NonEmptyList, NonEmptySet, Validated} import cats.laws.discipline._ import cats.kernel.laws.discipline.{EqTests, MonoidTests, OrderTests, PartialOrderTests, SemigroupTests} +import org.scalatest.funsuite.AnyFunSuiteLike + import scala.util.Try class EitherSuite extends CatsSuite { @@ -361,7 +363,18 @@ class EitherSuite extends CatsSuite { either.leftFlatMap(f) should ===(either.swap.flatMap(a => f(a).swap).swap) } } +} + +final class EitherInstancesSuite extends AnyFunSuiteLike { + test("parallel instance in cats.instances.either") { + import cats.instances.either._ + import cats.instances.string._ + import cats.syntax.parallel._ + + def either: Either[String, Int] = Left("Test") + (either, either).parTupled + } } @deprecated("To test deprecated methods", "2.1.0") diff --git a/tests/src/test/scala/cats/tests/ListSuite.scala b/tests/src/test/scala/cats/tests/ListSuite.scala index c5301365f1..b5bb2061d9 100644 --- a/tests/src/test/scala/cats/tests/ListSuite.scala +++ b/tests/src/test/scala/cats/tests/ListSuite.scala @@ -13,6 +13,7 @@ import cats.laws.discipline.{ TraverseTests } import cats.laws.discipline.arbitrary._ +import org.scalatest.funsuite.AnyFunSuiteLike class ListSuite extends CatsSuite { @@ -60,3 +61,13 @@ class ListSuite extends CatsSuite { } } } + +final class ListInstancesSuite extends AnyFunSuiteLike { + + test("NonEmptyParallel instance in cats.instances.list") { + import cats.instances.list._ + import cats.syntax.parallel._ + + (List(1, 2, 3), List("A", "B", "C")).parTupled + } +} diff --git a/tests/src/test/scala/cats/tests/ParallelSuite.scala b/tests/src/test/scala/cats/tests/ParallelSuite.scala index d1b4168aac..8d052df629 100644 --- a/tests/src/test/scala/cats/tests/ParallelSuite.scala +++ b/tests/src/test/scala/cats/tests/ParallelSuite.scala @@ -493,7 +493,6 @@ class ParallelSuite extends CatsSuite with ApplicativeErrorForEitherTest with Sc trait ApplicativeErrorForEitherTest extends AnyFunSuiteLike with Discipline { import cats.instances.either._ - import cats.instances.parallel._ import cats.instances.string._ import cats.instances.int._ import cats.instances.unit._ diff --git a/tests/src/test/scala/cats/tests/StreamSuite.scala b/tests/src/test/scala/cats/tests/StreamSuite.scala index e97d92dbbb..3a22bc4b9a 100644 --- a/tests/src/test/scala/cats/tests/StreamSuite.scala +++ b/tests/src/test/scala/cats/tests/StreamSuite.scala @@ -13,6 +13,7 @@ import cats.laws.discipline.{ } import cats.data.ZipStream import cats.laws.discipline.arbitrary._ +import org.scalatest.funsuite.AnyFunSuiteLike class StreamSuite extends CatsSuite { checkAll("Stream[Int]", SemigroupalTests[Stream].semigroupal[Int, Int, Int]) @@ -59,3 +60,13 @@ class StreamSuite extends CatsSuite { } } + +final class StreamInstancesSuite extends AnyFunSuiteLike { + + test("parallel instance in cats.instances.stream") { + import cats.instances.stream._ + import cats.syntax.parallel._ + + (Stream(1, 2, 3), Stream("A", "B", "C")).parTupled + } +} diff --git a/tests/src/test/scala/cats/tests/VectorSuite.scala b/tests/src/test/scala/cats/tests/VectorSuite.scala index 0f89646539..515b1cf52d 100644 --- a/tests/src/test/scala/cats/tests/VectorSuite.scala +++ b/tests/src/test/scala/cats/tests/VectorSuite.scala @@ -13,6 +13,7 @@ import cats.laws.discipline.{ TraverseTests } import cats.laws.discipline.arbitrary._ +import org.scalatest.funsuite.AnyFunSuiteLike class VectorSuite extends CatsSuite { checkAll("Vector[Int]", SemigroupalTests[Vector].semigroupal[Int, Int, Int]) @@ -55,3 +56,13 @@ class VectorSuite extends CatsSuite { assert(Vector.empty[Int].toNev == None) } } + +final class VectorInstancesSuite extends AnyFunSuiteLike { + + test("NonEmptyParallel instance in cats.instances.vector") { + import cats.instances.vector._ + import cats.syntax.parallel._ + + (Vector(1, 2, 3), Vector("A", "B", "C")).parTupled + } +}