arrow-core-data / arrow.core / kotlin.collections.Map / unalign
fun <K, A, B> Map<K, Ior<A, B>>.unalign(): Pair<Map<K, A>, Map<K, B>>
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: (Entry<K, C>) -> Ior<A, B>): Pair<Map<K, A>, Map<K, B>>
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)
}
Do you like Arrow?
✖