Packages

c

cats.syntax

EitherOps

final class EitherOps[A, B] extends AnyVal

Source
either.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EitherOps
  2. AnyVal
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new EitherOps(eab: Either[A, B])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    Any
  2. final def ##(): Int
    Definition Classes
    Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    Any
  4. def ===[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: Eq[AA], BB: Eq[BB]): Boolean
  5. def ap[AA >: A, BB >: B, C](that: Either[AA, (BB) ⇒ C]): Either[AA, C]
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def bimap[C, D](fa: (A) ⇒ C, fb: (B) ⇒ D): Either[C, D]
  8. 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 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)
  9. def compare[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: Order[AA], BB: Order[BB]): Int
  10. def ensure[AA >: A](onFailure: ⇒ AA)(f: (B) ⇒ Boolean): Either[AA, B]
  11. def ensureOr[AA >: A](onFailure: (B) ⇒ AA)(f: (B) ⇒ Boolean): Either[AA, B]
  12. def foldLeft[C](c: C)(f: (C, B) ⇒ C): C
  13. def foldRight[C](lc: Eval[C])(f: (B, Eval[C]) ⇒ Eval[C]): Eval[C]
  14. def getClass(): Class[_ <: AnyVal]
    Definition Classes
    AnyVal → Any
  15. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  16. def leftFlatMap[C, BB >: B](f: (A) ⇒ Either[C, BB]): Either[C, BB]
  17. def leftMap[C](f: (A) ⇒ C): Either[C, B]
  18. def liftTo[F[_]](implicit 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)))
  19. def map2Eval[AA >: A, C, Z](fc: Eval[Either[AA, C]])(f: (B, C) ⇒ Z): Eval[Either[AA, Z]]
  20. def orElse[C, BB >: B](fallback: ⇒ Either[C, BB]): Either[C, BB]
  21. def partialCompare[AA >: A, BB >: B](that: Either[AA, BB])(implicit AA: PartialOrder[AA], BB: PartialOrder[BB]): Double
  22. def recover[BB >: B](pf: PartialFunction[A, BB]): Either[A, BB]
  23. def recoverWith[AA >: A, BB >: B](pf: PartialFunction[A, Either[AA, BB]]): Either[AA, BB]
  24. def show[AA >: A, BB >: B](implicit AA: Show[AA], BB: Show[BB]): String
  25. def to[F[_]](implicit F: Alternative[F]): F[B]
  26. def toEitherNec[AA >: A]: EitherNec[AA, B]
  27. def toEitherNel[AA >: A]: EitherNel[AA, B]
  28. def toEitherNes[AA >: A](implicit O: Order[AA]): EitherNes[AA, B]
  29. 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)))
  30. def toIor: Ior[A, B]
  31. def toList: List[B]
  32. def toString(): String
    Definition Classes
    Any
  33. def toValidated: Validated[A, B]
  34. 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.

  35. def traverse[F[_], AA >: A, D](f: (B) ⇒ F[D])(implicit F: Applicative[F]): F[Either[AA, D]]
  36. def valueOr[BB >: B](f: (A) ⇒ BB): BB
  37. def withValidated[AA, BB](f: (Validated[A, B]) ⇒ Validated[AA, BB]): Either[AA, BB]

Deprecated Value Members

  1. def raiseOrPure[F[_]](implicit ev: ApplicativeError[F, A]): F[B]
    Annotations
    @deprecated
    Deprecated

    (Since version 2.0.0) use liftTo instead

Inherited from AnyVal

Inherited from Any

Ungrouped