Stewart Stewart
catch
thanh
inline fun <R> catch(f: () -> R, predicate: (Throwable) -> Boolean): Either<Throwable, R> = try { f().right() } catch (t: Throwable) { t.nonFatalOrThrow() if (predicate(t.nonFatalOrThrow())) t.left() else throw t }
catch(f) {it as SpecificException}
Giulio Caccin
inline fun <A, B> Either<A, B>.filterLeft(predicate: (A) -> Boolean, default: () -> B): Either<A, B> = swap().filterOrElse(predicate, default).swap()
as
R
A modern programming language that makes developers happier.