//arrow-core/arrow.core/align

align

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

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)
}

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

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)
}

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

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())
}

common fun <A, B> Sequence<A>.align(b: Sequence<B>): Sequence<Ior<A, B»

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())
}

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

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)
}

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

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)
}

Do you like Arrow?

Arrow Org
<