final class EitherOps[A, B] extends AnyVal
- Alphabetic
- By Inheritance
- EitherOps
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new EitherOps(eab: Either[A, B])
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- Any
-
final
def
##(): Int
- Definition Classes
- Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- Any
- def ===[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: Eq[AA], BB: Eq[BB]): Boolean
- def ap[AA >: A, BB >: B, C](that: Either[AA, (BB) ⇒ C]): Either[AA, C]
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- def bimap[C, D](fa: (A) ⇒ C, fb: (B) ⇒ D): Either[C, D]
-
final
def
combine[AA >: A, BB >: B](that: Either[AA, BB])(implicit BB: Semigroup[BB]): Either[AA, BB]
Combine with another
Either
value.Combine with another
Either
value.If this
Either
is aLeft
then it will be returned as-is. If thisEither
is aRight
andthat
Either
is a left, thenthat
will be returned. If bothEither
s areRight
s, then theSemigroup[BB]
instance will be used to combine both values and return them as aRight
. Note: If bothEither
s areLeft
s then their values are not combined. UseValidated
if you prefer to combineLeft
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])(implicit 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
getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- 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[_]](implicit F: ApplicativeError[F, _ >: A]): F[B]
lift the
Either
into aF[_]
withApplicativeError[F, A]
instancelift the
Either
into aF[_]
withApplicativeError[F, A]
instancescala> 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])(implicit 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](implicit AA: Show[AA], BB: Show[BB]): String
- def to[F[_]](implicit F: Alternative[F]): F[B]
- def toEitherNec[AA >: A]: EitherNec[AA, B]
- def toEitherNel[AA >: A]: EitherNel[AA, B]
- def toEitherNes[AA >: A](implicit O: Order[AA]): EitherNes[AA, B]
-
def
toEitherT[F[_]](implicit arg0: 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
toString(): String
- Definition Classes
- Any
- def toValidated: Validated[A, 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 theInvalid
side of the cats.data.NonEmptyList. - def traverse[F[_], AA >: A, D](f: (B) ⇒ F[D])(implicit 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 Value Members
-
def
raiseOrPure[F[_]](implicit ev: ApplicativeError[F, A]): F[B]
- Annotations
- @deprecated
- Deprecated
(Since version 2.0.0) use liftTo instead