Both

data class Both<out A, out B>(val leftValue: A, val rightValue: B) : Ior<A, B> (source)

Constructors

Link copied to clipboard
constructor(leftValue: A, rightValue: B)

Properties

Link copied to clipboard
open override val isBoth: Boolean

Returns true if this is a Both, false otherwise.

Link copied to clipboard
open override val isLeft: Boolean

Returns true if this is a Left, false otherwise.

Link copied to clipboard
open override val isRight: Boolean

Returns true if this is a Right, false otherwise.

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun <A, B> Ior<A, B>.combine(other: Ior<A, B>, combineA: (A, A) -> A, combineB: (B, B) -> B): Ior<A, B>
Link copied to clipboard
operator fun <A : Comparable<A>, B : Comparable<B>> Ior<A, B>.compareTo(other: Ior<A, B>): Int
Link copied to clipboard
inline fun <A, B, D> Ior<A, B>.flatMap(combine: (A, A) -> A, f: (B) -> Ior<A, D>): Ior<A, D>

Binds the given function across Ior.Right.

Link copied to clipboard
inline fun <A, B> Ior<A, Ior<A, B>>.flatten(combine: (A, A) -> A): Ior<A, B>
Link copied to clipboard
inline fun <C> fold(fa: (A) -> C, fb: (B) -> C, fab: (A, B) -> C): C

Applies fa if this is a Left, fb if this is a Right or fab if this is a Both

Link copied to clipboard
inline fun <A, B> Ior<A, B>.getOrElse(default: (A) -> B): B
Link copied to clipboard
fun getOrNull(): B?
Link copied to clipboard
@JvmName(name = "_isBoth")
fun isBoth(): Boolean

inline fun isBoth(leftPredicate: (A) -> Boolean, rightPredicate: (B) -> Boolean): Boolean

Returns false if Right or Left, or returns the result of the application of the given predicate to the Both value.

Link copied to clipboard
@JvmName(name = "_isLeft")
fun isLeft(): Boolean

inline fun isLeft(predicate: (A) -> Boolean): Boolean

Returns false if Right or Both, or returns the result of the application of the given predicate to the Left value.

Link copied to clipboard
@JvmName(name = "_isRight")
fun isRight(): Boolean

inline fun isRight(predicate: (B) -> Boolean): Boolean

Returns false if Left or Both, or returns the result of the application of the given predicate to the Right value.

Link copied to clipboard
fun leftOrNull(): A?

Returns the Left value or A if this is Left or Both and null if this is a Right.

Link copied to clipboard
inline fun <D> map(f: (B) -> D): Ior<A, D>

The given function is applied if this is a Right or Both to B.

Link copied to clipboard
inline fun <C> mapLeft(fa: (A) -> C): Ior<C, B>

The given function is applied if this is a Left or Both to A.

Link copied to clipboard
fun swap(): Ior<B, A>

If this is a Left, then return the left value in Right or vice versa, when this is Both , left and right values are swap

Link copied to clipboard
fun toEither(): Either<A, B>

Returns a Either.Right containing the Right value or B if this is Right or Both and Either.Left if this is a Left.

Link copied to clipboard
fun <A, B> Ior<A, B>.toIorNel(): IorNel<A, B>

Given an Ior with an error type A, returns an IorNel with the same error type. Wraps the original error in a NonEmptyList so that it can be combined with an IorNel in a Raise DSL which operates on one.

Link copied to clipboard
fun toPair(): Pair<A?, B?>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun unwrap(): Either<Either<A, B>, Pair<A, B>>

Return the isomorphic Either of this Ior