From 0fc6bd93c8462fbadee28cefa5423e1806e510d6 Mon Sep 17 00:00:00 2001 From: Kit Langton Date: Sun, 6 Feb 2022 11:20:11 -0500 Subject: [PATCH] fix free parallel --- .../scala/parallelfor/test/FreeParallel.scala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/test/scala/parallelfor/test/FreeParallel.scala b/src/test/scala/parallelfor/test/FreeParallel.scala index 82635e7..00cc654 100644 --- a/src/test/scala/parallelfor/test/FreeParallel.scala +++ b/src/test/scala/parallelfor/test/FreeParallel.scala @@ -13,12 +13,15 @@ sealed trait FreeParallel[-R, +E, +A] extends Product with Serializable { self = def traceImpl: (Trace, A) - def flatMap[R1 <: R, E1 >: E, B](f: A => FreeParallel[R1, E1, B])(implicit - dummyImplicit: DummyImplicit - ): FreeParallel[R1, E1, B] = + def zipPar[R1 <: R, E1 >: E, B](that: FreeParallel[R1, E1, B])(implicit + zippable: Zippable[A, B] + ): FreeParallel[R1, E1, zippable.Out] = + FreeParallel.ZipPar(self, that).map { case (a, b) => zippable.zip(a, b) } + + def flatMap[R1 <: R, E1 >: E, B](f: A => FreeParallel[R1, E1, B]): FreeParallel[R1, E1, B] = FreeParallel.FlatMap(this, f) - def map[R1 <: R, E1 >: E, B](f: A => B)(implicit dummyImplicit: DummyImplicit): FreeParallel[R1, E1, B] = + def map[B](f: A => B): FreeParallel[R, E, B] = FreeParallel.Map(this, f) } @@ -26,7 +29,7 @@ object FreeParallel { def effect[A](a: A): FreeParallel[Any, Nothing, A] = FreeParallel.Succeed(a) - final case class ZipPar[R, E, A, B](left: FreeParallel[R, E, A], right: FreeParallel[R, E, B]) + final case class ZipPar[-R, +E, +A, +B](left: FreeParallel[R, E, A], right: FreeParallel[R, E, B]) extends FreeParallel[R, E, (A, B)] { override def traceImpl: (Trace, (A, B)) = { val (lhsTrace, lhsValue) = left.traceImpl @@ -36,7 +39,7 @@ object FreeParallel { } } - final case class FlatMap[R, E, A, B](fa: FreeParallel[R, E, A], f: A => FreeParallel[R, E, B]) + final case class FlatMap[-R, +E, A, +B](fa: FreeParallel[R, E, A], f: A => FreeParallel[R, E, B]) extends FreeParallel[R, E, B] { override def traceImpl: (Trace, B) = { @@ -47,7 +50,7 @@ object FreeParallel { } } - final case class Map[R, E, A, B](fa: FreeParallel[R, E, A], f: A => B) extends FreeParallel[R, E, B] { + final case class Map[-R, +E, A, +B](fa: FreeParallel[R, E, A], f: A => B) extends FreeParallel[R, E, B] { override def traceImpl: (Trace, B) = { val (faTrace, faValue) = fa.traceImpl