Skip to content

Commit

Permalink
core: fix pattern matching
Browse files Browse the repository at this point in the history
  • Loading branch information
satorg committed Oct 21, 2022
1 parent df0a8da commit 275a9eb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/EitherT.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1186,13 +1186,13 @@ private[data] trait EitherTSemigroupK[F[_], L] extends SemigroupK[EitherT[F, L,
def combineK[A](x: EitherT[F, L, A], y: EitherT[F, L, A]): EitherT[F, L, A] =
EitherT(F.flatMap(x.value) {
case r @ Right(_) => F.pure(r)
case _ => y.value
case Left(_) => y.value
})

override def combineKEval[A](x: EitherT[F, L, A], y: Eval[EitherT[F, L, A]]): Eval[EitherT[F, L, A]] =
Eval.now(EitherT(F.flatMap(x.value) {
case r @ Right(_) => F.pure(r: Either[L, A])
case _ => y.value.value
case Left(_) => y.value.value
}))
}

Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/cats/data/Ior.scala
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ sealed abstract private[data] class IorInstances extends IorInstances0 {
ff match {
case Ior.Left(e2) => Ior.Left(E.combine(e2, e1))
case Ior.Both(e2, _) => Ior.Left(E.combine(e2, e1))
case _ => Ior.Left(e1)
case Ior.Right(_) => Ior.Left(e1)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/data/Validated.scala
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,8 @@ sealed abstract private[data] class ValidatedInstances extends ValidatedInstance
}
case Valid(a) =>
fb match {
case Valid(b) => Valid(f(Ior.both(a, b)))
case _ => Valid(f(Ior.left(a)))
case Valid(b) => Valid(f(Ior.both(a, b)))
case Invalid(_) => Valid(f(Ior.left(a)))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/cats/instances/either.scala
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ trait EitherInstances extends cats.kernel.instances.EitherInstances {
case Right(b) =>
fc match {
case Right(c) => Right(f(Ior.both(b, c)))
case _ => Right(f(Ior.left(b)))
case Left(_) => Right(f(Ior.left(b)))
}
case left @ Left(_) =>
fc match {
case Right(c) => Right(f(Ior.right(c)))
case _ => left.rightCast[D]
case Left(_) => left.rightCast[D]
}
}

Expand Down

0 comments on commit 275a9eb

Please sign in to comment.