ensure

inline fun <A, B> Either<A, B>.ensure(error: () -> A, predicate: (B) -> Boolean): Either<A, B>

Deprecated

This API is considered redundant. If this method is crucial for you, please let us know on the Arrow Github. Thanks! https://github.com/arrow-kt/arrow/issues Prefer if-else statement inside either DSL, or replace with explicit flatMap

Replace with

flatMap { b -> b.takeIf(predicate)?.right() ?: default().left() }

inline fun <A> Option<A>.ensure(error: () -> Unit, predicate: (A) -> Boolean): Option<A>

Deprecated

This API is considered redundant. If this method is crucial for you, please let us know on the Arrow Github. Thanks! https://github.com/arrow-kt/arrow/issues Prefer if-else statement inside option DSL, or replace with explicit flatMap

Replace with

import arrow.core.Some
import arrow.core.None
this.flatMap { b -> b.takeIf(predicate)?.let(::Some) ?: None.also(error) }