Package-level declarations

Types

Link copied to clipboard
sealed interface Maybe<out Element>

Container interface that is used to describe that there is either some value wrapped in the data class Some or the None data object. It's a copy of Option from Rust stdlib.

Link copied to clipboard
data object None : Maybe<Nothing>

Just a simple marker of a value absence that is a part of Maybe purpose. See its docs for more.

Link copied to clipboard
data class Some<out Element>(val value: Element) : Maybe<Element>

Just a simple value container that is a part of Maybe purpose. See its docs for more.

Functions

Link copied to clipboard
inline fun <Element, Result> Maybe<Element>.computeOn(compute: (Element) -> Result): Maybe<Result>

Computes the compute on the value and returns it wrapped in Some if the value is present or just returns None otherwise.

Link copied to clipboard
inline fun <Element, Result> Maybe<Element>.computeOnOrDefault(default: Result, compute: (Element) -> Result): Result

Computes the compute on the value and returns it if the value is present or just returns default one otherwise.

Link copied to clipboard
inline fun <Element, Result> Maybe<Element>.computeOnOrElse(default: () -> Result, compute: (Element) -> Result): Result

Computes the compute on the value and returns it if the value is present or just computes and returns default one otherwise.

Link copied to clipboard

Returns the wrapped in Some instance of type Maybe<E> if it is present or None otherwise.

Link copied to clipboard
fun Maybe<*>.isNone(): Boolean

Returns true if the value is absent.

Link copied to clipboard
fun Maybe<*>.isSome(): Boolean

Returns true if the value is present.

Link copied to clipboard

Wraps this value in Some if it is not null or returns None otherwise.

Link copied to clipboard

Returns the value if it is present or default one otherwise.

Link copied to clipboard
inline fun <Element> Maybe<Element>.orElse(default: () -> Element): Element

Returns the value if it is present or computes and returns default one otherwise.

Link copied to clipboard
inline fun <Element> Maybe<Element>.orThrow(error: () -> Throwable): Element

Returns the value if it is present or throws the provided exception otherwise.

Link copied to clipboard

Transforms this value with transform function and wraps result in Some if this value is not null or returns None otherwise.