align

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

Combines two structures by taking the union of their shapes and combining the elements with the given function.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
listOf("A", "B").align(listOf(1, 2, 3)) {
"$it"
}
//sampleEnd
println(result)
}

fun <A, B> Iterable<A>.align(b: Iterable<B>): List<Ior<A, B>>(source)

Combines two structures by taking the union of their shapes and using Ior to hold the elements.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
listOf("A", "B").align(listOf(1, 2, 3))
//sampleEnd
println(result)
}

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

Combines two structures by taking the union of their shapes and combining the elements with the given function.

import arrow.core.align

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

Combines two structures by taking the union of their shapes and using Ior to hold the elements.

import arrow.core.align

fun main(args: Array<String>) {
//sampleStart
val result =
sequenceOf("A", "B").align(sequenceOf(1, 2, 3))
//sampleEnd
println(result.toList())
}

fun <K, A, B> Map<K, A>.align(b: Map<K, B>): Map<K, Ior<A, B>>(source)

Combines two structures by taking the union of their shapes and using Ior to hold the elements.

import arrow.core.*

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

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

Combines two structures by taking the union of their shapes and combining the elements with the given function.

import arrow.core.*

fun main(args: Array<String>) {
//sampleStart
val result =
mapOf("1" to 1, "2" to 2).align(mapOf("1" to 1, "2" to 2, "3" to 3)) { (_, a) ->
"$a"
}
//sampleEnd
println(result)
}