sealed trait These[+A, +B] extends AnyRef
These
is a data type representing a value that may either be a Left
with anA
, a Right
with a B
, or a Both
with an A
and a B
.
These
can be useful to model certain domains where both values may be
present in addition to one or the other. For example, in streaming
applications we may want to consume values from two upstream producers
concurrently. Depending on the timing of the producers either one producer,
the other, or both producers may have values that are ready to be consumed.
Using These
provides a convenient way to model all of these possibilities
in a single "flat" data type.
These
can also be useful for representing computations that may produce
both a value and an error. For example, transferring money between two bank
accounts might either succeed, fail completely if there are not sufficient
funds, or succeed with some warnings if the sender's account balance would
be very low after the transfer or the receiver's account has not been
verified. These
allows modeling these types of computations and preserving
information regarding all errors while still potentially returning a
successful computation.
- Self Type
- These[A, B]
- Alphabetic
- By Inheritance
- These
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def &>[A1 >: A, C](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, C]
A symbolic alias for
zipParRight
. - final def *>[A1 >: A, C](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, C]
A symbolic alias for
zipRight
. - final def <&[A1 >: A, C](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, B]
A symbolic alias for
zipParLeft
. - final def <&>[A1 >: A, C](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, (B, C)]
A symbolic alias for
zipPar
. - final def <*[A1 >: A, C](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, B]
A symbolic alias for
zipLeft
. - final def <*>[A1 >: A, C](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, (B, C)]
A symbolic alias for
zip
. - final def <+>[A1 >: A, C](that: => These[A1, C])(implicit arg0: Associative[A1]): These[A1, Either[B, C]]
A symbolic alias for
orElseEither
. - final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def >>=[A1 >: A, C](f: (B) => These[A1, C])(implicit arg0: Associative[A1]): These[A1, C]
A symbolic alias for
flatMap
. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def bimap[A2, C](f: (A) => A2, g: (B) => C): These[A2, C]
Transforms both the
A
value and theB
value with the specified functionsf
andg
. - def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def flatMap[A1 >: A, C](f: (B) => These[A1, C])(implicit arg0: Associative[A1]): These[A1, C]
Returns a new computation based on the successful result of this computation.
Returns a new computation based on the successful result of this computation. If this computation contains a success the new computation will be performed, even if this computation also contains errors. Any errors produced by the two computations will be combined using the
Associative
instance forA
. If this computation does not contain a success then the original failure will be returned unchanged. - final def flatten[A1 >: A, C](implicit ev: <:<[B, These[A1, C]], ev2: Associative[A1]): These[A1, C]
Flattens a nested
These
computation to a single level. - final def flip: These[B, A]
Flips the left and right values.
- final def fold[C](left: (A) => C, right: (B) => C)(both: (A, B) => C): C
Folds each of the possibile cases into a summary value.
- final def forEach[F[+_], C](f: (B) => F[C])(implicit arg0: IdentityBoth[F], arg1: Covariant[F]): F[These[A, C]]
Transforms the successful result of this compuation with the specified effectual function, leaving any error value unchanged.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isBoth: Boolean
Returns whether this value is a
Both
. - final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def isLeft: Boolean
Returns whether this value is a
Left
. - final def isRight: Boolean
Returns whether this value is a
Right
. - final def map[C](f: (B) => C): These[A, C]
Transforms the
B
value with the specified function. - final def mapLeft[A2](f: (A) => A2): These[A2, B]
Transforms the
A
value with the specified function. - final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def orElse[A1 >: A, B1 >: B](that: => These[A1, B1])(implicit arg0: Associative[A1]): These[A1, B1]
- final def orElseEither[A1 >: A, C](that: => These[A1, C])(implicit arg0: Associative[A1]): These[A1, Either[B, C]]
- def reduceMap[C](f: (A) => C, g: (B) => C)(implicit C: Associative[C]): C
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def toEither: Either[A, B]
Converts this value to an
Either
containing aRight
if this value contains a success or aLeft
otherwise, discarding information about any errors in the case of success. - final def toOption: Option[B]
Converts this value to an
Option
containingSome
if this value contains a success orNone
otherwise, discarding information about any errors in the case of success. - def toString(): String
- Definition Classes
- AnyRef → Any
- final def toValidation: Validation[A, B]
Converts this value to a validation success if this value contains a success or a validation failure otherwise, discarding information about any errors in the case of success.
- final def toValidationNonEmptyChunk[A1](implicit ev: <:<[A, NonEmptyChunk[A1]]): Validation[A1, B]
Converts this value to a validation success if this value contains a success or a validation failure otherwise, submerging multiple errors into the structure of the validation and discarding information about any errors in the case of success.
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def zip[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, (B, C)]
Combines this computation sequentially with that computation, combining their results into a tuple.
Combines this computation sequentially with that computation, combining their results into a tuple. If this computation does not return a success that computation will not be performed. If both computations are performed any errors will be combined using the
Associative
instance forA
. - final def zipLeft[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, B]
Combines this computation sequentially with that computation, returning only the left value.
Combines this computation sequentially with that computation, returning only the left value. If this computation does not return a success that computation will not be performed. If both computations are performed any errors will be combined using the
Associative
instance forA
. - final def zipPar[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, (B, C)]
Combines this computation with that computation into a tuple, performing both computations even if this computation does not return a success and combining any errors using the
Commutative
instance forA
. - final def zipParLeft[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, B]
Combines this computation with that computation and returning only the left value, performing both computations even if this computation does not return a success and combining any errors using the
Commutative
instance forA
. - final def zipParRight[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Commutative[A1]): These[A1, C]
Combines this computation with that computation and returning only the right value, performing both computations even if this computation does not return a success and combining any errors using the
Commutative
instance forA
. - final def zipRight[A1 >: A, C, D](that: These[A1, C])(implicit arg0: Associative[A1]): These[A1, C]
Combines this computation sequentially with that computation, returning only the right value.
Combines this computation sequentially with that computation, returning only the right value. If this computation does not return a success that computation will not be performed. If both computations are performed any errors will be combined using the
Associative
instance forA
. - final def zipWith[A1 >: A, C, D](that: These[A1, C])(f: (B, C) => D)(implicit arg0: Associative[A1]): These[A1, D]
Combines this computation sequentially with that computation, combining their results with the specified function.
Combines this computation sequentially with that computation, combining their results with the specified function. If this computation does not return a success that computation will not be performed. If both computations are performed any errors will be combined using the
Associative
instance forA
. - final def zipWithPar[A1 >: A, C, D](that: These[A1, C])(f: (B, C) => D)(implicit arg0: Commutative[A1]): These[A1, D]
Combines this computation with that computation using the specified function, performing both computations even if this computation does not return a success and combining any errors using the
Commutative
instance forA
.