kotest-assertions-arrow / io.kotest.assertions.arrow.either / io.kotest.properties.Gen / either

either

fun <A, B> Gen.Companion.either(GA: Gen<A>, GB: Gen<B>): Gen<Either<A, B>>

Gen extension instance for Either.

Generates random Right and Left values based on the constants provided by the GA and GB generators.

import io.kotest.assertions.arrow.either.either
import io.kotest.properties.forAll
import io.kotest.properties.Gen

forAll(Gen.either(Gen.constant(1), Gen.constant(0))) {
  it.fold({ l -> l == 1 }, { r -> r == 0 })
}