maybe

inline fun <Ok : Any> Ok.maybe(isSuccess: Ok.() -> Boolean): Maybe<Ok>

Wraps a value of type Ok as a Maybe based on a isSuccess.

If the isSuccess returns true, the value is wrapped as a Success. If the isSuccess returns false, an emptyFailure is returned.

Return

A Maybe containing the value as a Success or an emptyFailure.

Parameters

Ok

The type of the value to wrap.

isSuccess

A function that determines if the value is successful.


val <T> T.maybe: Maybe<T & Any>

Wrap any T as an Maybe.

Return

An Maybe containing the value as a Success or an emptyFailure.

Parameters

T

The type of the value to wrap.