ensure Not Null
suspend fun <R, B : Any> ContEffect<R>.ensureNotNull(value: B?, shift: () -> R): B
Content copied to clipboard
Ensure that value is not null
. if it's non-null it will be smart-casted and returned if it's false
it will shift
with the provided value R. Monadic version of kotlin.requireNotNull.
suspend fun test() = checkAll(Arb.string(), Arb.int().orNull()) { failure, int: Int? ->
cont<String, Int> {
ensureNotNull(int) { failure }
}.toEither() shouldBe (int?.right() ?: failure.left())
}
Content copied to clipboard