EitherOps

final class EitherOps[A, B](eab: Either[A, B]) extends AnyVal
class AnyVal
trait Matchable
class Any

Value members

Concrete methods

def ===[AA >: A, BB >: B](that: Either[AA, BB])(AA: Eq[AA], BB: Eq[BB]): Boolean
def ap[AA >: A, BB >: B, C](that: Either[AA, BB => C]): Either[AA, C]
def bimap[C, D](fa: A => C, fb: B => D): Either[C, D]
final def combine[AA >: A, BB >: B](that: Either[AA, BB])(BB: Semigroup[BB]): Either[AA, BB]

Combine with another Either value.

Combine with another Either value.

If this Either is a Left then it will be returned as-is. If this Either is a Right and that Either is a left, then that will be returned. If both Eithers are Rights, then the Semigroup[BB] instance will be used to combine both values and return them as a Right. Note: If both Eithers are Lefts then their values are not combined. Use Validated if you prefer to combine Left values.

Examples:

scala> import cats.implicits._
scala> val l1: Either[String, Int] = Either.left("error 1")
scala> val l2: Either[String, Int] = Either.left("error 2")
scala> val r3: Either[String, Int] = Either.right(3)
scala> val r4: Either[String, Int] = Either.right(4)

scala> l1 combine l2
res0: Either[String, Int] = Left(error 1)

scala> l1 combine r3
res1: Either[String, Int] = Left(error 1)

scala> r3 combine l1
res2: Either[String, Int] = Left(error 1)

scala> r3 combine r4
res3: Either[String, Int] = Right(7)
def compare[AA >: A, BB >: B](that: Either[AA, BB])(AA: Order[AA], BB: Order[BB]): Int
def ensure[AA >: A](onFailure: => AA)(f: B => Boolean): Either[AA, B]
def ensureOr[AA >: A](onFailure: B => AA)(f: B => Boolean): Either[AA, B]
def foldLeft[C](c: C)(f: (C, B) => C): C
def foldRight[C](lc: Eval[C])(f: (B, Eval[C]) => Eval[C]): Eval[C]
def leftFlatMap[C, BB >: B](f: A => Either[C, BB]): Either[C, BB]
def leftMap[C](f: A => C): Either[C, B]
def liftTo[F[_]](F: ApplicativeError[F, _ >: A]): F[B]

lift the Either into a F[_] with ApplicativeError[F, A] instance

lift the Either into a F[_] with ApplicativeError[F, A] instance

scala> import cats.implicits._
scala> import cats.data.EitherT
scala> val e: Either[String, Int] = Right(3)
scala> e.liftTo[EitherT[Option, CharSequence, *]]
res0: cats.data.EitherT[Option, CharSequence, Int] = EitherT(Some(Right(3)))
def map2Eval[AA >: A, C, Z](fc: Eval[Either[AA, C]])(f: (B, C) => Z): Eval[Either[AA, Z]]
def orElse[C, BB >: B](fallback: => Either[C, BB]): Either[C, BB]
def partialCompare[AA >: A, BB >: B](that: Either[AA, BB])(AA: PartialOrder[AA], BB: PartialOrder[BB]): Double
def recover[BB >: B](pf: PartialFunction[A, BB]): Either[A, BB]
def recoverWith[AA >: A, BB >: B](pf: PartialFunction[A, Either[AA, BB]]): Either[AA, BB]
def show[AA >: A, BB >: B](AA: Show[AA], BB: Show[BB]): String
def to[F[_]](F: Alternative[F]): F[B]
def toEitherNec[AA >: A]: EitherNec[AA, B]
def toEitherNel[AA >: A]: EitherNel[AA, B]
def toEitherNes[AA >: A](O: Order[AA]): EitherNes[AA, B]
def toEitherT[F[_]](`evidence$1`: Applicative[F]): EitherT[F, A, B]

Transform the Either into a cats.data.EitherT while lifting it into the specified Applicative.

Transform the Either into a cats.data.EitherT while lifting it into the specified Applicative.

scala> import cats.implicits._
scala> val e: Either[String, Int] = Right(3)
scala> e.toEitherT[Option]
res0: cats.data.EitherT[Option, String, Int] = EitherT(Some(Right(3)))
def toIor: Ior[A, B]
def toList: List[B]
def toValidatedNel[AA >: A]: ValidatedNel[AA, B]

Returns a cats.data.ValidatedNel representation of this disjunction with the Left value as a single element on the Invalid side of the cats.data.NonEmptyList.

Returns a cats.data.ValidatedNel representation of this disjunction with the Left value as a single element on the Invalid side of the cats.data.NonEmptyList.

def traverse[F[_], AA >: A, D](f: B => F[D])(F: Applicative[F]): F[Either[AA, D]]
def valueOr[BB >: B](f: A => BB): BB
def withValidated[AA, BB](f: Validated[A, B] => Validated[AA, BB]): Either[AA, BB]

Deprecated methods

@deprecated("use liftTo instead", "2.0.0")
def raiseOrPure[F[_]](ev: ApplicativeError[F, A]): F[B]
Deprecated