Packages

object EitherT extends EitherTInstances with Serializable

Source
EitherT.scala
Linear Supertypes
Serializable, Serializable, EitherTInstances, EitherTInstances1, EitherTInstances2, EitherTInstances3, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EitherT
  2. Serializable
  3. Serializable
  4. EitherTInstances
  5. EitherTInstances1
  6. EitherTInstances2
  7. EitherTInstances3
  8. AnyRef
  9. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def accumulatingParallel[M[_], E](implicit arg0: Semigroup[E], P: Parallel[M]): Aux[[γ$23$]EitherT[M, E, γ$23$], [γ$24$]Nested[Parallel.F, [β$22$]Validated[E, β$22$], γ$24$]]

    An alternative Parallel implementation which merges the semantics of the outer Parallel (the F[_] effect) with the effects of the inner one (the Either).

    An alternative Parallel implementation which merges the semantics of the outer Parallel (the F[_] effect) with the effects of the inner one (the Either). The inner Parallel has the semantics of Validated, while the outer has the semantics of parallel evaluation (in most cases). The default Parallel for EitherT, when the nested F also has a Parallel, is to strictly take the semantics of the nested F and to short-circuit any lefts (often, errors) in a left-to-right fashion, mirroring the semantics of Applicative on EitherT. This instance is different in that it will not short-circuit but instead accumulate all lefts according to the supplied Semigroup, similar to Validated.

    implicit val p: Parallel[EitherT[IO, Chain[Error], *]] = EitherT.accumulatingParallel
    
    val a = EitherT(IO(Chain(error1).asLeft[Unit]))
    val b = EitherT(IO(Chain(error2).asLeft[Unit]))
    
    (a, b).parTupled  // => EitherT(IO(Chain(error1, error2).asLeft[Unit]))
    Definition Classes
    EitherTInstances
  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. implicit def catsDataBifunctorForEitherT[F[_]](implicit F: Functor[F]): Bifunctor[[β$14$, γ$15$]EitherT[F, β$14$, γ$15$]]
    Definition Classes
    EitherTInstances
  7. implicit def catsDataBitraverseForEitherT[F[_]](implicit F: Traverse[F]): Bitraverse[[β$69$, γ$70$]EitherT[F, β$69$, γ$70$]]
    Definition Classes
    EitherTInstances1
  8. implicit def catsDataDeferForEitherT[F[_], L](implicit F: Defer[F]): Defer[[γ$17$]EitherT[F, L, γ$17$]]
    Definition Classes
    EitherTInstances
  9. implicit def catsDataEqForEitherT[F[_], L, R](implicit F: Eq[F[Either[L, R]]]): Eq[EitherT[F, L, R]]
    Definition Classes
    EitherTInstances2
  10. implicit def catsDataFoldableForEitherT[F[_], L](implicit F: Foldable[F]): Foldable[[γ$68$]EitherT[F, L, γ$68$]]
    Definition Classes
    EitherTInstances1
  11. implicit def catsDataFunctorForEitherT[F[_], L](implicit F0: Functor[F]): Functor[[γ$99$]EitherT[F, L, γ$99$]]
    Definition Classes
    EitherTInstances3
  12. implicit def catsDataMonadErrorFForEitherT[F[_], E, L](implicit FE0: MonadError[F, E]): MonadError[[γ$97$]EitherT[F, L, γ$97$], E]

    Monad error instance for recovering errors in F instead of the underlying Either.

    Monad error instance for recovering errors in F instead of the underlying Either.

    scala> import cats.data.EitherT
    scala> import cats.MonadError
    scala> import cats.instances.option._
    scala> val noInt: Option[Either[String, Int]] = None
    scala> val et = EitherT[Option, String, Int](noInt)
    scala> val me = MonadError[EitherT[Option, String, *], Unit]
    scala> me.recover(et) { case () => 1 }
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(1)))
    Definition Classes
    EitherTInstances2
  13. implicit def catsDataMonadErrorForEitherT[F[_], L](implicit F0: Monad[F]): MonadError[[γ$71$]EitherT[F, L, γ$71$], L]
    Definition Classes
    EitherTInstances1
  14. implicit def catsDataOrderForEitherT[F[_], L, R](implicit F: Order[F[Either[L, R]]]): Order[EitherT[F, L, R]]
    Definition Classes
    EitherTInstances
  15. implicit def catsDataParallelForEitherTWithParallelEffect2[M[_], E](implicit P: Parallel[M]): Aux[[γ$46$]EitherT[M, E, γ$46$], [γ$47$]Nested[Parallel.F, [β$45$]Either[E, β$45$], γ$47$]]
    Definition Classes
    EitherTInstances
  16. implicit def catsDataParallelForEitherTWithSequentialEffect[M[_], E](implicit arg0: Monad[M], arg1: Semigroup[E]): Aux[[γ$73$]EitherT[M, E, γ$73$], [γ$74$]Nested[M, [β$72$]Validated[E, β$72$], γ$74$]]
    Definition Classes
    EitherTInstances1
  17. implicit def catsDataPartialOrderForEitherT[F[_], L, R](implicit F: PartialOrder[F[Either[L, R]]]): PartialOrder[EitherT[F, L, R]]
    Definition Classes
    EitherTInstances1
  18. implicit def catsDataSemigroupKForEitherT[F[_], L](implicit F0: Monad[F]): SemigroupK[[γ$98$]EitherT[F, L, γ$98$]]
    Definition Classes
    EitherTInstances2
  19. implicit def catsDataShowForEitherT[F[_], L, R](implicit sh: Show[F[Either[L, R]]]): Show[EitherT[F, L, R]]
    Definition Classes
    EitherTInstances
  20. implicit def catsDataTraverseForEitherT[F[_], L](implicit FF: Traverse[F]): Traverse[[γ$16$]EitherT[F, L, γ$16$]]
    Definition Classes
    EitherTInstances
  21. implicit def catsMonoidForEitherT[F[_], L, A](implicit F: Monoid[F[Either[L, A]]]): Monoid[EitherT[F, L, A]]
    Definition Classes
    EitherTInstances
  22. implicit def catsSemigroupForEitherT[F[_], L, A](implicit F: Semigroup[F[Either[L, A]]]): Semigroup[EitherT[F, L, A]]
    Definition Classes
    EitherTInstances1
  23. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @IntrinsicCandidate()
  24. final def cond[F[_]]: CondPartiallyApplied[F]

    If the condition is satisfied, return the given A in Right lifted into the specified Applicative, otherwise, return the given E in Left lifted into the specified Applicative.

    If the condition is satisfied, return the given A in Right lifted into the specified Applicative, otherwise, return the given E in Left lifted into the specified Applicative.

    scala> import cats.Id
    scala> import cats.data.EitherT
    scala> val userInput = "hello world"
    scala> EitherT.cond[Id](
         |   userInput.forall(_.isDigit) && userInput.size == 10,
         |   userInput,
         |   "The input does not look like a phone number")
    res0: EitherT[Id, String, String] = EitherT(Left(The input does not look like a phone number))
  25. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  26. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  27. final def fromEither[F[_]]: FromEitherPartiallyApplied[F]

    Transforms an Either into an EitherT, lifted into the specified Applicative.

    Transforms an Either into an EitherT, lifted into the specified Applicative.

    Note: The return type is a FromEitherPartiallyApplied[F], which has an apply method on it, allowing you to call fromEither like this:

    scala> import cats.implicits._
    scala> val t: Either[String, Int] = Either.right(3)
    scala> EitherT.fromEither[Option](t)
    res0: EitherT[Option, String, Int] = EitherT(Some(Right(3)))

    The reason for the indirection is to emulate currying type parameters.

  28. final def fromOption[F[_]]: FromOptionPartiallyApplied[F]

    Transforms an Option into an EitherT, lifted into the specified Applicative and using the second argument if the Option is a None.

    Transforms an Option into an EitherT, lifted into the specified Applicative and using the second argument if the Option is a None.

    scala> import cats.implicits._
    scala> val o: Option[Int] = None
    scala> EitherT.fromOption[List](o, "Answer not known.")
    res0: EitherT[List, String, Int]  = EitherT(List(Left(Answer not known.)))
    scala> EitherT.fromOption[List](Some(42), "Answer not known.")
    res1: EitherT[List, String, Int] = EitherT(List(Right(42)))
  29. final def fromOptionF[F[_], E, A](fopt: F[Option[A]], ifNone: ⇒ E)(implicit F: Functor[F]): EitherT[F, E, A]

    Transforms an F[Option] into an EitherT, using the second argument if the Option is a None.

    Transforms an F[Option] into an EitherT, using the second argument if the Option is a None.

    scala> import cats.implicits._
    scala> val o: Option[Int] = None
    scala> EitherT.fromOptionF(List(o), "Answer not known.")
    res0: EitherT[List, String, Int]  = EitherT(List(Left(Answer not known.)))
    scala> EitherT.fromOptionF(List(Option(42)), "Answer not known.")
    res1: EitherT[List, String, Int] = EitherT(List(Right(42)))
  30. final def fromOptionM[F[_], E, A](fopt: F[Option[A]], ifNone: ⇒ F[E])(implicit F: Monad[F]): EitherT[F, E, A]

    Similar to fromOptionF but the left is carried from monadic F[_] context when the option is None

  31. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  32. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @IntrinsicCandidate()
  33. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  34. final def left[B]: LeftPartiallyApplied[B]

    Creates a left version of EitherT[F, A, B] from a F[A]

    Creates a left version of EitherT[F, A, B] from a F[A]

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> EitherT.left[Int](Option("err"))
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Left(err)))
  35. final def leftT[F[_], B]: LeftTPartiallyApplied[F, B]

    Creates a left version of EitherT[F, A, B] from a A

    Creates a left version of EitherT[F, A, B] from a A

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> EitherT.leftT[Option, Int]("err")
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Left(err)))
  36. final def liftAttemptK[F[_], E](implicit F: ApplicativeError[F, E]): ~>[F, [γ$12$]EitherT[F, E, γ$12$]]

    Lifts an effect into EitherT, catching all errors from the effect and lifting them into EitherT's error channel.

    Lifts an effect into EitherT, catching all errors from the effect and lifting them into EitherT's error channel.

    scala> import cats._, data._, implicits._
    scala> val a: Option[Int] = None
    scala> val b: EitherT[Option, Unit, Int] = EitherT.liftAttemptK[Option, Unit].apply(a)
    scala> b.value
    res0: Option[Either[Unit, Int]] = Some(Left(()))
    
    scala> val a2: Option[Int] = Some(42)
    scala> val b2: EitherT[Option, Unit, Int] = EitherT.liftAttemptK[Option, Unit].apply(a2)
    scala> b2.value
    res1: Option[Either[Unit, Int]] = Some(Right(42))
  37. final def liftF[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B]

    Alias for right

    Alias for right

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> val o: Option[Int] = Some(3)
    scala> val n: Option[Int] = None
    scala> EitherT.liftF(o)
    res0: cats.data.EitherT[Option,Nothing,Int] = EitherT(Some(Right(3)))
    scala> EitherT.liftF(n)
    res1: cats.data.EitherT[Option,Nothing,Int] = EitherT(None)
  38. final def liftK[F[_], A](implicit F: Functor[F]): ~>[F, [γ$10$]EitherT[F, A, γ$10$]]

    Same as liftF, but expressed as a FunctionK for use with mapK

    Same as liftF, but expressed as a FunctionK for use with mapK

    scala> import cats._, data._, implicits._
    scala> val a: OptionT[Eval, Int] = 1.pure[OptionT[Eval, *]]
    scala> val b: OptionT[EitherT[Eval, String, *], Int] = a.mapK(EitherT.liftK)
    scala> b.value.value.value
    res0: Either[String,Option[Int]] = Right(Some(1))
  39. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  40. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  41. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @IntrinsicCandidate()
  42. final def pure[F[_], A]: PurePartiallyApplied[F, A]

    Creates a new EitherT[F, A, B] from a B

    Creates a new EitherT[F, A, B] from a B

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> EitherT.pure[Option, String](3)
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(3)))
  43. final def right[A]: RightPartiallyApplied[A]

    Creates a right version of EitherT[F, A, B] from a F[B]

    Creates a right version of EitherT[F, A, B] from a F[B]

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> EitherT.right[String](Option(3))
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(3)))
  44. final def rightT[F[_], A]: PurePartiallyApplied[F, A]

    Alias for pure

    Alias for pure

    scala> import cats.data.EitherT
    scala> import cats.implicits._
    scala> EitherT.rightT[Option, String](3)
    res0: cats.data.EitherT[Option,String,Int] = EitherT(Some(Right(3)))
  45. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  46. def toString(): String
    Definition Classes
    AnyRef → Any
  47. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  49. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def catsDataParallelForEitherTWithParallelEffect[M[_], E](implicit arg0: Semigroup[E], P: Parallel[M]): Aux[[γ$20$]EitherT[M, E, γ$20$], [γ$21$]Nested[Parallel.F, [β$19$]Validated[E, β$19$], γ$21$]]
    Definition Classes
    EitherTInstances
    Annotations
    @deprecated
    Deprecated

    (Since version 2.4.0) This implicit provides inconsistent effect layering semantics; see #3776 for more discussion

  2. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated
  3. final def liftT[F[_], A, B](fb: F[B])(implicit F: Functor[F]): EitherT[F, A, B]
    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.0-RC1) Use EitherT.liftF.

Inherited from Serializable

Inherited from Serializable

Inherited from EitherTInstances

Inherited from EitherTInstances1

Inherited from EitherTInstances2

Inherited from EitherTInstances3

Inherited from AnyRef

Inherited from Any

Ungrouped