arrow-core-data / arrow.core / kotlin.sequences.Sequence / unalign
fun <A, B>
Sequence
<
Ior
<A, B>>.unalign():
Pair
<
Sequence
<A>,
Sequence
<B>>
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>>
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()})")
}
Do you like Arrow?
✖