Bicrosswalk

The Bicrosswalk typeclass extends the Bifunctor and Bifoldable typeclass with the possibility to traverse the structure through an alignable functor.

Main Combinators

bicrosswalk

fun <A,B,C,D> bicrosswalk(ALIGN: Align<F>, fa: (A) -> Kind<F, C>, fb: (B) -> Kind<F, D>, tab: Kind2<T, A, B>): Kind<F, Kind2<T, C, D>>

import arrow.core.extensions.*
import arrow.core.extensions.either.bicrosswalk.bicrosswalk
import arrow.core.extensions.listk.align.align
import arrow.core.*

Either.bicrosswalk().run {
    val either = Either.Right("arrow")
    bicrosswalk(ListK.align(), either, {ListK.just("fa($it)")}) {ListK.just("fb($it)")}
}
// [Right(fb(arrow))]

sequenceL

fun <F, A, B> bisequenceL(ALIGN: Align<F>, tab: Kind2<T, Kind<F, A>, Kind<F, B>>): Kind<F, Kind2<T, A, B>>

import arrow.core.extensions.*
import arrow.core.extensions.either.bicrosswalk.bicrosswalk
import arrow.core.extensions.listk.align.align
import arrow.core.*

Either.bicrosswalk().run {
    val either: Either<ListK<Int>, ListK<String>> = Either.Right(listOf("hello", "arrow").k())
    bisequenceL(ListK.align(), either)
}
// [Right(hello), Right(arrow)]

Laws

Arrow provides BicrosswalkLaws in the form of test cases for internal verification of lawful instances and third party apps creating their own Bicrosswalk instances.

Creating your own Bicrosswalk instances

Arrow already provides Bicrosswalk instances for common datatypes (e.g. Either, Ior). See their implementations and accompanying testcases for reference.

See Deriving and creating custom typeclass

Additionally all instances of Bicrosswalk implement the Bifunctor and Bifoldable typeclass directly.

Data types

Module Data types
arrow.core Either, Ior

Type Class Hierarchy

Do you like Arrow?

Arrow Org
<