unalign

fun <A, B> Iterable<Ior<A, B>>.unalign(): Pair<List<A>, List<B>>(source)

splits a union into its component parts.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
listOf(("A" to 1).bothIor(), ("B" to 2).bothIor(), "C".leftIor())
.unalign()
//sampleEnd
println(result)
}

inline fun <A, B, C> Iterable<C>.unalign(fa: (C) -> Ior<A, B>): Pair<List<A>, List<B>>(source)

after applying the given function, splits the resulting union shaped structure into its components parts

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
listOf(1, 2, 3).unalign {
it.leftIor()
}
//sampleEnd
println(result)
}

fun <A, B> Option<Ior<A, B>>.unalign(): Pair<Option<A>, Option<B>>(source)
inline fun <A, B, C> Option<C>.unalign(f: (C) -> Ior<A, B>): Pair<Option<A>, Option<B>>(source)


splits an union into its component parts.

import arrow.core.bothIor
import arrow.core.leftIor
import arrow.core.unalign

fun main(args: Array<String>) {
//sampleStart
val result = sequenceOf(("A" to 1).bothIor(), ("B" to 2).bothIor(), "C".leftIor()).unalign()
//sampleEnd
println("(${result.first.toList()}, ${result.second.toList()})")
}

fun <A, B, C> Sequence<C>.unalign(fa: (C) -> Ior<A, B>): Pair<Sequence<A>, Sequence<B>>(source)

after applying the given function, splits the resulting union shaped structure into its components parts

import arrow.core.leftIor
import arrow.core.unalign

fun main(args: Array<String>) {
//sampleStart
val result = sequenceOf(1, 2, 3).unalign { it.leftIor() }
//sampleEnd
println("(${result.first.toList()}, ${result.second.toList()})")
}

fun <K, A, B> Map<K, Ior<A, B>>.unalign(): Pair<Map<K, A>, Map<K, B>>(source)

Splits a union into its component parts.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
mapOf(
"first" to ("A" to 1).bothIor(),
"second" to ("B" to 2).bothIor(),
"third" to "C".leftIor()
).unalign()
//sampleEnd
println(result)
}

fun <K, A, B, C> Map<K, C>.unalign(fa: (Map.Entry<K, C>) -> Ior<A, B>): Pair<Map<K, A>, Map<K, B>>(source)

after applying the given function, splits the resulting union shaped structure into its components parts

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
mapOf("1" to 1, "2" to 2, "3" to 3)
.unalign { it.leftIor() }
//sampleEnd
println(result)
}