diff --git a/core/src/main/scala/cats/Reducible.scala b/core/src/main/scala/cats/Reducible.scala index d0906f7f01..bf2f184689 100644 --- a/core/src/main/scala/cats/Reducible.scala +++ b/core/src/main/scala/cats/Reducible.scala @@ -192,13 +192,13 @@ import simulacrum.typeclass import cats.syntax.either._ def g(a: A, eval: Eval[Ior[NonEmptyList[B], NonEmptyList[C]]]): Eval[Ior[NonEmptyList[B], NonEmptyList[C]]] = { - val ior = eval.value + eval.map(ior => (f(a), ior) match { - case (Right(c), Ior.Left(_)) => Eval.now(ior.putRight(NonEmptyList.one(c))) - case (Right(c), _) => Eval.now(ior.map(c :: _)) - case (Left(b), Ior.Right(r)) => Eval.now(Ior.bothNel(b, r)) - case (Left(b), _) => Eval.now(ior.leftMap(b :: _)) - } + case (Right(c), Ior.Left(_)) => ior.putRight(NonEmptyList.one(c)) + case (Right(c), _) => ior.map(c :: _) + case (Left(b), Ior.Right(r)) => Ior.bothNel(b, r) + case (Left(b), _) => ior.leftMap(b :: _) + }) } reduceRightTo(fa)(a => f(a).bimap(NonEmptyList.one, NonEmptyList.one).toIor)(g).value diff --git a/tests/src/test/scala/cats/tests/ReducibleTests.scala b/tests/src/test/scala/cats/tests/ReducibleTests.scala index 1a8a1163c4..b262d66dad 100644 --- a/tests/src/test/scala/cats/tests/ReducibleTests.scala +++ b/tests/src/test/scala/cats/tests/ReducibleTests.scala @@ -109,11 +109,11 @@ abstract class ReducibleCheck[F[_]: Reducible: Functor](name: String)(implicit A val g: Int => Either[Double, String] = f andThen Right.apply val h: Int => Either[String, Double] = f andThen Left.apply - val withG = fi.partitionE(g).fold(_ => NonEmptyList.one(""), identity, (l,r) => r) - withG should === (Reducible[F].toNonEmptyList((fi.map(f)))) + val withG = fi.partitionE(g).right.getOrElse(NonEmptyList.one("")) + withG should === (Reducible[F].toNonEmptyList(fi.map(f))) - val withH = fi.partitionE(h).fold(identity, _ => NonEmptyList.one(""), (l,r) => l) - withH should === (Reducible[F].toNonEmptyList((fi.map(f)))) + val withH = fi.partitionE(h).left.getOrElse(NonEmptyList.one("")) + withH should === (Reducible[F].toNonEmptyList(fi.map(f))) } }