unalign
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)
}Content copied to clipboard
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)
}Content copied to clipboard
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()})")
}Content copied to clipboard
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()})")
}Content copied to clipboard
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)
}Content copied to clipboard
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)
}Content copied to clipboard
Deprecated
This API is niche and will be removed in the future. If this method is crucial for you, please let us know on the Arrow Github. Thanks! https://github.com/arrow-kt/arrow/issues Prefer using a when expression