EitherT

final case
class EitherT[A, F[_], B](run: F[A \/ B])

Represents a computation of type F[A \/ B].

Example:

val x: Option[String \/ Int] = Some(\/-(1))
EitherT(x).map(1+).run // Some(\/-(2))
Companion
object
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any

Type members

Classlikes

final
class Switching_\/[X](r: => X)

Value members

Concrete methods

def +++(x: => EitherT[A, F, B])(implicit M1: Semigroup[B], M2: Semigroup[A], F: Apply[F]): EitherT[A, F, B]

Sums up values inside disjunction, if both are left or right. Returns first left otherwise.

Sums up values inside disjunction, if both are left or right. Returns first left otherwise.

\/-(v1) +++ \/-(v2) → \/-(v1 + v2)
\/-(v1) +++ -\/(v2) → -\/(v2)
-\/(v1) +++ \/-(v2) → -\/(v1)
-\/(v1) +++ -\/(v2) → -\/(v1 + v2)
def ===(x: EitherT[A, F, B])(implicit EA: Equal[A], EB: Equal[B], F: Apply[F]): F[Boolean]

Compare two disjunction values for equality.

Compare two disjunction values for equality.

def app[C](f: => EitherT[A, F, B => C])(implicit F: Apply[F]): EitherT[A, F, C]

Apply a function in the environment of the right of this disjunction. Because it runs my F even when f's \/ fails, it is not consistent with ap.

Apply a function in the environment of the right of this disjunction. Because it runs my F even when f's \/ fails, it is not consistent with ap.

def bimap[C, D](f: A => C, g: B => D)(implicit F: Functor[F]): EitherT[C, F, D]

Binary functor map on this disjunction.

Binary functor map on this disjunction.

def bitraverse[G[_], C, D](f: A => G[C], g: B => G[D])(implicit F: Traverse[F], G: Applicative[G]): G[EitherT[C, F, D]]

Binary functor traverse on this disjunction.

Binary functor traverse on this disjunction.

def compare(x: EitherT[A, F, B])(implicit EA: Order[A], EB: Order[B], F: Apply[F]): F[Ordering]

Compare two disjunction values for ordering.

Compare two disjunction values for ordering.

def cozip(implicit Z: Cozip[F]): F[A] \/ F[B]

Cozip this disjunction on its functor.

Cozip this disjunction on its functor.

def ensure(onLeft: => A)(f: B => Boolean)(implicit F: Functor[F]): EitherT[A, F, B]

Ensures that the right value of this disjunction satisfies the given predicate, or returns left with the given value.

Ensures that the right value of this disjunction satisfies the given predicate, or returns left with the given value.

def exists(f: B => Boolean)(implicit F: Functor[F]): F[Boolean]

Return true if this disjunction is a right value satisfying the given predicate.

Return true if this disjunction is a right value satisfying the given predicate.

def filter(p: B => Boolean)(implicit M: Monoid[A], F: Monad[F]): EitherT[A, F, B]

Filter on the right of this disjunction.

Filter on the right of this disjunction.

def flatMap[C](f: B => EitherT[A, F, C])(implicit F: Monad[F]): EitherT[A, F, C]

Bind through the right of this disjunction.

Bind through the right of this disjunction.

def flatMapF[C](f: B => F[A \/ C])(implicit F: Monad[F]): EitherT[A, F, C]

Bind the inner monad through the right of this disjunction.

Bind the inner monad through the right of this disjunction.

def fold[X](l: A => X, r: B => X)(implicit F: Functor[F]): F[X]
def foldConst[X](l: => X, r: => X)(implicit F: Functor[F]): F[X]
def foldM[X](l: A => F[X], r: B => F[X])(implicit F: Bind[F]): F[X]
def foldRight[Z](z: => Z)(f: (B, => Z) => Z)(implicit F: Foldable[F]): Z

Fold on the right of this disjunction.

Fold on the right of this disjunction.

def forall(f: B => Boolean)(implicit F: Functor[F]): F[Boolean]

Return true if this disjunction is a left value or the right value satisfies the given predicate.

Return true if this disjunction is a left value or the right value satisfies the given predicate.

def getOrElse(default: => B)(implicit F: Functor[F]): F[B]

Return the right value of this disjunction or the given default if left. Alias for |

Return the right value of this disjunction or the given default if left. Alias for |

def isLeft(implicit F: Functor[F]): F[Boolean]

Return true if this disjunction is left.

Return true if this disjunction is left.

def isRight(implicit F: Functor[F]): F[Boolean]

Return true if this disjunction is right.

Return true if this disjunction is right.

def leftMap[C](f: A => C)(implicit F: Functor[F]): EitherT[C, F, B]

Run the given function on the left value.

Run the given function on the left value.

def map[C](f: B => C)(implicit F: Functor[F]): EitherT[A, F, C]

Map on the right of this disjunction.

Map on the right of this disjunction.

def mapF[C](f: B => F[C])(implicit M: Monad[F]): EitherT[A, F, C]

Map on the right of this disjunction.

Map on the right of this disjunction.

def mapT[G[_], C, D](f: F[A \/ B] => G[C \/ D]): EitherT[C, G, D]
def merge[AA >: A](implicit F: Functor[F], ev: Liskov[B, AA]): F[AA]

Return the value from whichever side of the disjunction is defined, given a commonly assignable type.

Return the value from whichever side of the disjunction is defined, given a commonly assignable type.

def orElse(x: => EitherT[A, F, B])(implicit F: Monad[F]): EitherT[A, F, B]

Return this if it is a right, otherwise, return the given value. Alias for |||

Return this if it is a right, otherwise, return the given value. Alias for |||

def show(implicit SA: Show[A], SB: Show[B], F: Functor[F]): F[Cord]

Show for a disjunction value.

Show for a disjunction value.

def swap(implicit F: Functor[F]): EitherT[B, F, A]

Flip the left/right values in this disjunction. Alias for swap

Flip the left/right values in this disjunction. Alias for swap

def swapped[AA, BB](k: B \/ A => BB \/ AA)(implicit F: Functor[F]): EitherT[AA, F, BB]

Run the given function on this swapped value. Alias for ~

Run the given function on this swapped value. Alias for ~

def toEither(implicit F: Functor[F]): F[Either[A, B]]

Convert to a core scala.Either at your own peril.

Convert to a core scala.Either at your own peril.

def toList(implicit F: Functor[F]): F[List[B]]

Return an empty list or list with one element on the right of this disjunction.

Return an empty list or list with one element on the right of this disjunction.

def toMaybe(implicit F: Functor[F]): MaybeT[F, B]

Return an empty option or option with one element on the right of this disjunction. Useful to sweep errors under the carpet.

Return an empty option or option with one element on the right of this disjunction. Useful to sweep errors under the carpet.

def toOption(implicit F: Functor[F]): OptionT[F, B]

Return an empty option or option with one element on the right of this disjunction. Useful to sweep errors under the carpet.

Return an empty option or option with one element on the right of this disjunction. Useful to sweep errors under the carpet.

def toStream(implicit F: Functor[F]): F[Stream[B]]

Return an empty stream or stream with one element on the right of this disjunction.

Return an empty stream or stream with one element on the right of this disjunction.

def toThese(implicit F: Functor[F]): TheseT[F, A, B]

Return a this on the left-side or a that on the right-side of this disjunction

Return a this on the left-side or a that on the right-side of this disjunction

def toValidation(implicit F: Functor[F]): F[Validation[A, B]]

Convert to a validation.

Convert to a validation.

def traverse[G[_], C](f: B => G[C])(implicit F: Traverse[F], G: Applicative[G]): G[EitherT[A, F, C]]

Traverse on the right of this disjunction.

Traverse on the right of this disjunction.

def unary_~(implicit F: Functor[F]): EitherT[B, F, A]

Flip the left/right values in this disjunction. Alias for unary_~

Flip the left/right values in this disjunction. Alias for unary_~

def validationed[AA, BB](k: Validation[A, B] => Validation[AA, BB])(implicit F: Functor[F]): EitherT[AA, F, BB]

Run a validation function and back to disjunction again.

Run a validation function and back to disjunction again.

def valueOr(x: A => B)(implicit F: Functor[F]): F[B]

Return the right value of this disjunction or run the given function on the left.

Return the right value of this disjunction or run the given function on the left.

def withFilter(p: B => Boolean)(implicit M: Monoid[A], F: Monad[F]): EitherT[A, F, B]

Alias for filter.

Alias for filter.

def |(default: => B)(implicit F: Functor[F]): F[B]

Return the right value of this disjunction or the given default if left. Alias for getOrElse

Return the right value of this disjunction or the given default if left. Alias for getOrElse

def |||(x: => EitherT[A, F, B])(implicit F: Monad[F]): EitherT[A, F, B]

Return this if it is a right, otherwise, return the given value. Alias for orElse

Return this if it is a right, otherwise, return the given value. Alias for orElse

def ~[AA, BB](k: B \/ A => BB \/ AA)(implicit F: Functor[F]): EitherT[AA, F, BB]

Run the given function on this swapped value. Alias for swapped

Run the given function on this swapped value. Alias for swapped

Deprecated methods

@deprecated("Due to SI-1980, <
def :?>>[X](right: => X): Switching_\/[X]

If this disjunction is right, return the given X value, otherwise, return the X value given to the return value.

If this disjunction is right, return the given X value, otherwise, return the X value given to the return value.

Deprecated
[Since version 7.3.0]
@deprecated("Use `toValidation`", "7.3.0")
def validation(implicit F: Functor[F]): F[Validation[A, B]]
Deprecated

Inherited methods

def productElementNames: Iterator[String]
Inherited from
Product
def productIterator: Iterator[Any]
Inherited from
Product