cats.data

XorT

final case class XorT[F[_], A, B](value: F[Xor[A, B]]) extends Product with Serializable

Transformer for Xor, allowing the effect of an arbitrary type constructor F to be combined with the fail-fast effect of Xor.

XorT[F, A, B] wraps a value of type F[A Xor B]. An F[C] can be lifted in to XorT[F, A, C] via XorT.right, and lifted in to a XorT[F, C, B] via XorT.left.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. XorT
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new XorT(value: F[Xor[A, B]])

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def ===(that: XorT[F, A, B])(implicit eq: Eq[F[Xor[A, B]]]): Boolean

  7. def applyAlt[D](ff: XorT[F, A, (B) ⇒ D])(implicit F: Apply[F]): XorT[F, A, D]

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def bimap[C, D](fa: (A) ⇒ C, fb: (B) ⇒ D)(implicit F: Functor[F]): XorT[F, C, D]

  10. def bitraverse[G[_], C, D](f: (A) ⇒ G[C], g: (B) ⇒ G[D])(implicit traverseF: Traverse[F], applicativeG: Applicative[G]): G[XorT[F, C, D]]

  11. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def collectRight(implicit F: MonadCombine[F]): F[B]

  13. def combine(that: XorT[F, A, B])(implicit F: Apply[F], B: Semigroup[B]): XorT[F, A, B]

    Similar to Xor.combine but mapped over an F context.

    Similar to Xor.combine but mapped over an F context.

    Examples:

    scala> import cats.data.XorT
    scala> import cats.implicits._
    scala> val l1: XorT[Option, String, Int] = XorT.left(Some("error 1"))
    scala> val l2: XorT[Option, String, Int] = XorT.left(Some("error 2"))
    scala> val r3: XorT[Option, String, Int] = XorT.right(Some(3))
    scala> val r4: XorT[Option, String, Int] = XorT.right(Some(4))
    scala> val noneXorT: XorT[Option, String, Int] = XorT.left(None)
    
    scala> l1 combine l2
    res0: XorT[Option, String, Int] = XorT(Some(Left(error 1)))
    
    scala> l1 combine r3
    res1: XorT[Option, String, Int] = XorT(Some(Left(error 1)))
    
    scala> r3 combine l1
    res2: XorT[Option, String, Int] = XorT(Some(Left(error 1)))
    
    scala> r3 combine r4
    res3: XorT[Option, String, Int] = XorT(Some(Right(7)))
    
    scala> l1 combine noneXorT
    res4: XorT[Option, String, Int] = XorT(None)
    
    scala> noneXorT combine l1
    res5: XorT[Option, String, Int] = XorT(None)
    
    scala> r3 combine noneXorT
    res6: XorT[Option, String, Int] = XorT(None)
    
    scala> noneXorT combine r4
    res7: XorT[Option, String, Int] = XorT(None)
  14. def compare(that: XorT[F, A, B])(implicit o: Order[F[Xor[A, B]]]): Int

  15. def ensure[AA >: A](onFailure: ⇒ AA)(f: (B) ⇒ Boolean)(implicit F: Functor[F]): XorT[F, AA, B]

  16. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. def exists(f: (B) ⇒ Boolean)(implicit F: Functor[F]): F[Boolean]

  18. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  19. def flatMap[AA >: A, D](f: (B) ⇒ XorT[F, AA, D])(implicit F: Monad[F]): XorT[F, AA, D]

  20. def flatMapF[AA >: A, D](f: (B) ⇒ F[Xor[AA, D]])(implicit F: Monad[F]): XorT[F, AA, D]

  21. def fold[C](fa: (A) ⇒ C, fb: (B) ⇒ C)(implicit F: Functor[F]): F[C]

  22. def foldLeft[C](c: C)(f: (C, B) ⇒ C)(implicit F: Foldable[F]): C

  23. def foldRight[C](lc: Eval[C])(f: (B, Eval[C]) ⇒ Eval[C])(implicit F: Foldable[F]): Eval[C]

  24. def forall(f: (B) ⇒ Boolean)(implicit F: Functor[F]): F[Boolean]

  25. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  26. def getOrElse[BB >: B](default: ⇒ BB)(implicit F: Functor[F]): F[BB]

  27. def getOrElseF[BB >: B](default: ⇒ F[BB])(implicit F: Monad[F]): F[BB]

  28. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  29. def isLeft(implicit F: Functor[F]): F[Boolean]

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

  31. def leftMap[C](f: (A) ⇒ C)(implicit F: Functor[F]): XorT[F, C, B]

  32. def map[D](f: (B) ⇒ D)(implicit F: Functor[F]): XorT[F, A, D]

  33. def merge[AA >: A](implicit ev: <:<[B, AA], F: Functor[F]): F[AA]

  34. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  35. final def notify(): Unit

    Definition Classes
    AnyRef
  36. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  37. def orElse[AA, BB >: B](default: ⇒ XorT[F, AA, BB])(implicit F: Monad[F]): XorT[F, AA, BB]

  38. def partialCompare(that: XorT[F, A, B])(implicit p: PartialOrder[F[Xor[A, B]]]): Double

  39. def recover(pf: PartialFunction[A, B])(implicit F: Functor[F]): XorT[F, A, B]

  40. def recoverWith(pf: PartialFunction[A, XorT[F, A, B]])(implicit F: Monad[F]): XorT[F, A, B]

  41. def show(implicit show: Show[F[Xor[A, B]]]): String

  42. def subflatMap[AA >: A, D](f: (B) ⇒ Xor[AA, D])(implicit F: Functor[F]): XorT[F, AA, D]

  43. def swap(implicit F: Functor[F]): XorT[F, B, A]

  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def to[G[_]](implicit functorF: Functor[F], monoidKG: MonoidK[G], applicativeG: Applicative[G]): F[G[B]]

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

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

  48. def toValidated(implicit F: Functor[F]): F[Validated[A, B]]

  49. def transform[C, D](f: (Xor[A, B]) ⇒ Xor[C, D])(implicit F: Functor[F]): XorT[F, C, D]

  50. def traverse[G[_], D](f: (B) ⇒ G[D])(implicit traverseF: Traverse[F], applicativeG: Applicative[G]): G[XorT[F, A, D]]

  51. val value: F[Xor[A, B]]

  52. def valueOr[BB >: B](f: (A) ⇒ BB)(implicit F: Functor[F]): F[BB]

  53. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  55. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  56. def withValidated[AA, BB](f: (Validated[A, B]) ⇒ Validated[AA, BB])(implicit F: Functor[F]): XorT[F, AA, BB]

    Run this value as a Validated against the function and convert it back to an XorT.

    Run this value as a Validated against the function and convert it back to an XorT.

    The Applicative instance for XorT "fails fast" - it is often useful to "momentarily" have it accumulate errors instead, which is what the Validated data type gives us.

    Example:

    scala> import cats.std.option._
    scala> import cats.std.list._
    scala> import cats.syntax.cartesian._
    scala> type Error = String
    scala> val v1: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 1"))
    scala> val v2: Validated[NonEmptyList[Error], Int] = Validated.Invalid(NonEmptyList("error 2"))
    scala> val xort: XorT[Option, Error, Int] = XorT(Some(Xor.left("error 3")))
    scala> xort.withValidated { v3 => (v1 |@| v2 |@| v3.leftMap(NonEmptyList(_))).map{ case (i, j, k) => i + j + k } }
    res0: XorT[Option, NonEmptyList[Error], Int] = XorT(Some(Left(OneAnd(error 1,List(error 2, error 3)))))

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped