cont
DSL for constructing Cont values
suspend fun test() {
cont<String, Int> {
val x = Either.Right(1).bind()
val y = Validated.Valid(2).bind()
val z = Option(3).bind { "Option was empty" }
x + y + z
}.fold({ fail("Shift can never be the result") }, { it shouldBe 6 })
cont<String, Int> {
val x = Either.Right(1).bind()
val y = Validated.Valid(2).bind()
val z: Int = None.bind { "Option was empty" }
x + y + z
}.fold({ it shouldBe "Option was empty" }, { fail("Int can never be the result") })
}
Content copied to clipboard
Sources
common source
Link copied to clipboard