# Both

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

## Constructors

fun <out A, out B> Both(leftValue: A, rightValue: B)

## Functions

inline fun all(predicate: (B) -> Boolean): Boolean
inline fun <C, D> bicrosswalk(fa: (A) -> Iterable<C>, fb: (B) -> Iterable<D>): List<Ior<C, D>>
inline fun <C, D, K> bicrosswalkMap(fa: (A) -> Map<K, C>, fb: (B) -> Map<K, D>): Map<K, Ior<C, D>>
inline fun <C, D> bicrosswalkNull(fa: (A) -> C?, fb: (B) -> D?): Ior<C, D>?
inline fun <C> bifoldLeft(c: C, f: (C, A) -> C, g: (C, B) -> C): C
inline fun <C> bifoldMap(MN: Monoid<C>, f: (A) -> C, g: (B) -> C): C
inline fun <C, D> bimap(fa: (A) -> C, fb: (B) -> D): Ior<C, D>

Apply `fa` if this is a Left or Both to `A` and apply `fb` if this is Right or Both to `B`

inline fun <AA, C> bitraverse(fa: (A) -> Iterable<AA>, fb: (B) -> Iterable<C>): List<Ior<AA, C>>
inline fun <AA, C, D> bitraverseEither(fa: (A) -> Either<AA, C>, fb: (B) -> Either<AA, D>): Either<AA, Ior<C, D>>
inline fun <C, D> bitraverseNullable(fa: (A) -> C?, fb: (B) -> D?): Ior<C, D>?
inline fun <C, D> bitraverseOption(fa: (A) -> Option<C>, fb: (B) -> Option<D>): Option<Ior<C, D>>
inline fun <AA, C, D> bitraverseValidated(SA: Semigroup<AA>, fa: (A) -> Validated<AA, C>, fb: (B) -> Validated<AA, D>): Validated<AA, Ior<C, D>>
inline fun <C> crosswalk(fa: (B) -> Iterable<C>): List<Ior<A, C>>
inline fun <K, V> crosswalkMap(fa: (B) -> Map<K, V>): Map<K, Ior<A, V>>
inline fun <A, B, C> crosswalkNull(ior: Ior<A, B>, fa: (B) -> C?): Ior<A, C>?
inline fun exists(predicate: (B) -> Boolean): Boolean

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

inline fun findOrNull(predicate: (B) -> Boolean): B?
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

inline fun <C> foldLeft(c: C, f: (C, B) -> C): C
inline fun <C> foldMap(MN: Monoid<C>, f: (B) -> C): C
fun leftOrNull(): A?

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

inline fun <D> map(f: (B) -> D): Ior<A, D>

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

inline fun <C> mapLeft(fa: (A) -> C): Ior<C, B>

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

fun orNull(): B?

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

Return this Ior as Pair of nullables]

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

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.

open override fun toString(): String

Returns a Validated.Valid containing the Right value or `B` if this is Right or Both and Validated.Invalid if this is a Left.

inline fun <AA, C> traverse(fa: (B) -> Either<AA, C>): Either<AA, Ior<A, C>>
inline fun <C> traverse(fa: (B) -> Option<C>): Option<Ior<A, C>>
inline fun <AA, C> traverse(fa: (B) -> Validated<AA, C>): Validated<AA, Ior<A, C>>
inline fun <C> traverse(fa: (B) -> Iterable<C>): List<Ior<A, C>>
inline fun <C> traverseNullable(fa: (B) -> C?): Ior<A, C>?
fun unwrap(): Either<Either<A, B>, Pair<A, B>>

Return the isomorphic Either of this Ior

fun void(): Ior<A, Unit>

## Properties

open override val isBoth: Boolean

Returns `true` if this is a Both, `false` otherwise.

open override val isLeft: Boolean

Returns `true` if this is a Left, `false` otherwise.

open override val isRight: Boolean

Returns `true` if this is a Right, `false` otherwise.

## Extensions

fun <A, B> Ior<Iterable<A>, Iterable<B>>.bisequence(): List<Ior<A, B>>
fun <A, B, C> Ior<Either<A, B>, Either<A, C>>.bisequenceEither(): Either<A, Ior<B, C>>
fun <B, C> Ior<B?, C?>.bisequenceNullable(): Ior<B, C>?
fun <A, B> Ior<A, B>.combine(SA: Semigroup<A>, SB: Semigroup<B>, other: Ior<A, B>): Ior<A, B>
operator fun <A : Comparable<A>, B : Comparable<B>> Ior<A, B>.compareTo(other: Ior<A, B>): Int
inline fun <A, B, D> Ior<A, B>.flatMap(SG: Semigroup<A>, f: (B) -> Ior<A, D>): Ior<A, D>

Binds the given function across Ior.Right.

inline fun <A, B> Ior<A, Ior<A, B>>.flatten(SA: Semigroup<A>): Ior<A, B>
inline fun <A, B> Ior<A, B>.getOrElse(default: () -> B): B
fun <AA, A : AA, B> Ior<A, B>.leftWiden(): Ior<AA, B>
fun <A, B> Ior<A, B>.replicate(SA: Semigroup<A>, n: Int): Ior<A, List<B>>
fun <A, B> Ior<A, B>.replicate(SA: Semigroup<A>, n: Int, MB: Monoid<B>): Ior<A, B>
fun <A, B> Ior<A, Iterable<B>>.sequence(): List<Ior<A, B>>
fun <A, B, C> Ior<A, Either<B, C>>.sequence(): Either<B, Ior<A, C>>
fun <A, B> Ior<A, Option<B>>.sequence(): Option<Ior<A, B>>
fun <A, B> Ior<A, B?>.sequence(): Ior<A, B>?
fun <A, B, C> Ior<A, Validated<B, C>>.sequence(): Validated<B, Ior<A, C>>
fun <A, C, B : C> Ior<A, B>.widen(): Ior<A, C>

Given B is a sub type of C, re-type this value from Ior to Ior