From ca3cb7234d27793331f9e76a357b52c94e532ed2 Mon Sep 17 00:00:00 2001 From: Travis Brown Date: Sat, 7 Sep 2019 07:26:07 -0500 Subject: [PATCH] Add Parallel.apply overload with one type parameter --- core/src/main/scala/cats/Parallel.scala | 2 ++ .../test/scala/cats/tests/ParallelSuite.scala | 20 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/src/main/scala/cats/Parallel.scala b/core/src/main/scala/cats/Parallel.scala index bd41a97323..065ffbe0e2 100644 --- a/core/src/main/scala/cats/Parallel.scala +++ b/core/src/main/scala/cats/Parallel.scala @@ -110,12 +110,14 @@ object NonEmptyParallel { type Aux[M[_], F0[_]] = NonEmptyParallel[M] { type F[x] = F0[x] } def apply[M[_], F[_]](implicit P: NonEmptyParallel.Aux[M, F]): NonEmptyParallel.Aux[M, F] = P + def apply[M[_]](implicit P: NonEmptyParallel[M], D: DummyImplicit): NonEmptyParallel.Aux[M, P.F] = P } object Parallel extends ParallelArityFunctions2 { type Aux[M[_], F0[_]] = Parallel[M] { type F[x] = F0[x] } def apply[M[_], F[_]](implicit P: Parallel.Aux[M, F]): Parallel.Aux[M, F] = P + def apply[M[_]](implicit P: Parallel[M], D: DummyImplicit): Parallel.Aux[M, P.F] = P /** * Like `Traverse[A].sequence`, but uses the applicative instance diff --git a/tests/src/test/scala/cats/tests/ParallelSuite.scala b/tests/src/test/scala/cats/tests/ParallelSuite.scala index de4d21e511..c0537fa6d5 100644 --- a/tests/src/test/scala/cats/tests/ParallelSuite.scala +++ b/tests/src/test/scala/cats/tests/ParallelSuite.scala @@ -477,6 +477,26 @@ class ParallelSuite extends CatsSuite with ApplicativeErrorForEitherTest with Sc ) } + test("NonEmptyParallel.apply should return an appropriately typed instance given both type parameters") { + val p1: NonEmptyParallel.Aux[Either[String, *], Validated[String, *]] = + NonEmptyParallel[Either[String, *], Validated[String, *]] + val p2: NonEmptyParallel.Aux[NonEmptyList, ZipNonEmptyList] = NonEmptyParallel[NonEmptyList, ZipNonEmptyList] + } + + test("NonEmptyParallel.apply should return an appropriately typed instance given the first type parameter") { + val p1: NonEmptyParallel.Aux[Either[String, *], Validated[String, *]] = NonEmptyParallel[Either[String, *]] + val p2: NonEmptyParallel.Aux[NonEmptyList, ZipNonEmptyList] = NonEmptyParallel[NonEmptyList] + } + + test("Parallel.apply should return an appropriately typed instance given both type parameters") { + val p1: Parallel.Aux[Either[String, *], Validated[String, *]] = Parallel[Either[String, *], Validated[String, *]] + val p2: Parallel.Aux[Stream, ZipStream] = Parallel[Stream, ZipStream] + } + + test("Parallel.apply should return an appropriately typed instance given the first type parameter") { + val p1: Parallel.Aux[Either[String, *], Validated[String, *]] = Parallel[Either[String, *], Validated[String, *]] + val p2: Parallel.Aux[Stream, ZipStream] = Parallel[Stream] + } } trait ApplicativeErrorForEitherTest extends AnyFunSuiteLike with Discipline {