Some

data class Some<out T>(val value: T) : Option<T> (source)

Constructors

Link copied to clipboard
fun <out T> Some(value: T)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
infix fun <B> align(b: Option<B>): Option<Ior<T, B>>

Align two options (this on the left and b on the right) as one Option of Ior.

inline fun <B, C> align(b: Option<B>, f: (Ior<T, B>) -> C): Option<C>

Align two options (this on the left and b on the right) as one Option of Ior, and then, if it's not None, map it using f.

Link copied to clipboard
inline fun all(predicate: (T) -> Boolean): Boolean

Returns true if this option is empty '''or''' the predicate $predicate returns true when applied to this $option's value.

Link copied to clipboard
infix fun <X> and(value: Option<X>): Option<X>
Link copied to clipboard
inline fun <B> crosswalk(f: (T) -> Option<B>): Option<Option<B>>
Link copied to clipboard
inline fun <K, V> crosswalkMap(f: (T) -> Map<K, V>): Map<K, Option<V>>
Link copied to clipboard
inline fun <B> crosswalkNull(f: (T) -> B?): Option<B>?
Link copied to clipboard
inline fun exists(predicate: (T) -> Boolean): Boolean

Returns true if this option is nonempty '''and''' the predicate $p returns true when applied to this $option's value. Otherwise, returns false.

Link copied to clipboard
inline fun filter(predicate: (T) -> Boolean): Option<T>

Returns this $option if it is nonempty '''and''' applying the predicate $p to this $option's value returns true. Otherwise, return $none.

Link copied to clipboard
inline fun filterNot(predicate: (T) -> Boolean): Option<T>

Returns this $option if it is nonempty '''and''' applying the predicate $p to this $option's value returns false. Otherwise, return $none.

Link copied to clipboard
inline fun findOrNull(predicate: (T) -> Boolean): T?

Returns the $option's value if this option is nonempty '''and''' the predicate $p returns true when applied to this $option's value. Otherwise, returns null.

Link copied to clipboard
inline fun <B> flatMap(f: (T) -> Option<B>): Option<B>

Returns the result of applying $f to this $option's value if this $option is nonempty. Returns $none if this $option is empty. Slightly different from map in that $f is expected to return an $option (which could be $none).

Link copied to clipboard
inline fun <R> fold(ifEmpty: () -> R, ifSome: (T) -> R): R
Link copied to clipboard
inline fun <B> foldLeft(initial: B, operation: (B, T) -> B): B
Link copied to clipboard
inline fun <B> foldMap(MB: Monoid<B>, f: (T) -> B): B
Link copied to clipboard

Returns true if the option is an instance of Some, false otherwise.

Link copied to clipboard
open override fun isEmpty(): Boolean

Returns true if the option is None, false otherwise.

Link copied to clipboard
Link copied to clipboard
inline fun <B> map(f: (T) -> B): Option<B>

Returns a Some<$B> containing the result of applying $f to this $option's value if this $option is nonempty. Otherwise return $none.

Link copied to clipboard
inline fun <B> mapNotNull(f: (T) -> B?): Option<B>

Returns $none if the result of applying $f to this $option's value is null. Otherwise returns the result.

Link copied to clipboard

alias for isDefined

Link copied to clipboard
fun orNull(): T?
Link copied to clipboard
fun <B> padZip(other: Option<B>): Option<Pair<T?, B?>>
inline fun <B, C> padZip(other: Option<B>, f: (T?, B?) -> C): Option<C>
Link copied to clipboard
fun <L> pairLeft(left: L): Option<Pair<L, T>>
Link copied to clipboard
fun <R> pairRight(right: R): Option<Pair<T, R>>
Link copied to clipboard
inline fun <B> reduceOrNull(initial: (T) -> B, operation: (acc: B, T) -> B): B?
Link copied to clipboard
inline fun <B> reduceRightEvalOrNull(initial: (T) -> B, operation: (T, acc: Eval<B>) -> Eval<B>): Eval<B?>
Link copied to clipboard
Link copied to clipboard
inline fun tap(f: (T) -> Unit): Option<T>

The given function is applied as a fire and forget effect if this is a some. When applied the result is ignored and the original Some value is returned

Link copied to clipboard
inline fun tapNone(f: () -> Unit): Option<T>

The given function is applied as a fire and forget effect if this is a None. When applied the result is ignored and the original None value is returned

Link copied to clipboard
inline fun <L> toEither(ifEmpty: () -> L): Either<L, T>
Link copied to clipboard
fun toList(): List<T>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
inline fun <AA, B> traverse(fa: (T) -> Either<AA, B>): Either<AA, Option<B>>
inline fun <AA, B> traverse(fa: (T) -> Validated<AA, B>): Validated<AA, Option<B>>
inline fun <B> traverse(fa: (T) -> Iterable<B>): List<Option<B>>
Link copied to clipboard
fun void(): Option<Unit>
Link copied to clipboard
fun <B> zip(other: Option<B>): Option<Pair<T, B>>
inline fun <B, C> zip(b: Option<B>, map: (T, B) -> C): Option<C>
inline fun <B, C, D> zip(b: Option<B>, c: Option<C>, map: (T, B, C) -> D): Option<D>
inline fun <B, C, D, E> zip(b: Option<B>, c: Option<C>, d: Option<D>, map: (T, B, C, D) -> E): Option<E>
inline fun <B, C, D, E, F> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, map: (T, B, C, D, E) -> F): Option<F>
inline fun <B, C, D, E, F, G> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, f: Option<F>, map: (T, B, C, D, E, F) -> G): Option<G>
inline fun <B, C, D, E, F, G, H> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, f: Option<F>, g: Option<G>, map: (T, B, C, D, E, F, G) -> H): Option<H>
inline fun <B, C, D, E, F, G, H, I> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, f: Option<F>, g: Option<G>, h: Option<H>, map: (T, B, C, D, E, F, G, H) -> I): Option<I>
inline fun <B, C, D, E, F, G, H, I, J> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, f: Option<F>, g: Option<G>, h: Option<H>, i: Option<I>, map: (T, B, C, D, E, F, G, H, I) -> J): Option<J>
inline fun <B, C, D, E, F, G, H, I, J, K> zip(b: Option<B>, c: Option<C>, d: Option<D>, e: Option<E>, f: Option<F>, g: Option<G>, h: Option<H>, i: Option<I>, j: Option<J>, map: (T, B, C, D, E, F, G, H, I, J) -> K): Option<K>

Properties

Link copied to clipboard
val value: T

Extensions

Link copied to clipboard
fun <A> Option<A>.combine(SGA: Semigroup<A>, b: Option<A>): Option<A>
Link copied to clipboard
operator fun <A : Comparable<A>> Option<A>.compareTo(other: Option<A>): Int
Link copied to clipboard
inline fun <A> Option<A>.ensure(error: () -> Unit, predicate: (A) -> Boolean): Option<A>
Link copied to clipboard
inline fun <B> Option<*>.filterIsInstance(): Option<B>

Returns an Option containing all elements that are instances of specified type parameter B.

Link copied to clipboard
Link copied to clipboard
inline fun <T> Option<T>.getOrElse(default: () -> T): T

Returns the option's value if the option is nonempty, otherwise return the result of evaluating default.

Link copied to clipboard
inline fun <A> Option<A>.handleError(f: (Unit) -> A): Option<A>
Link copied to clipboard
inline fun <A> Option<A>.handleErrorWith(f: (Unit) -> Option<A>): Option<A>
Link copied to clipboard
infix fun <T> Option<T>.or(value: Option<T>): Option<T>
Link copied to clipboard
inline fun <A> Option<A>.orElse(alternative: () -> Option<A>): Option<A>

Returns this option's if the option is nonempty, otherwise returns another option provided lazily by default.

Link copied to clipboard
inline fun <A, B> Option<A>.redeem(fe: (Unit) -> B, fb: (A) -> B): Option<B>
Link copied to clipboard
inline fun <A, B> Option<A>.redeemWith(fe: (Unit) -> Option<B>, fb: (A) -> Option<B>): Option<B>
Link copied to clipboard
fun <A> Option<A>.replicate(n: Int, MA: Monoid<A>): Option<A>
Link copied to clipboard
Link copied to clipboard
fun <A> Option<A>.salign(SA: Semigroup<A>, b: Option<A>): Option<A>
Link copied to clipboard

Separate the inner Either value into the Either.Left and Either.Right.

Link copied to clipboard

Separate the inner Validated value into the Validated.Invalid and Validated.Valid.

Link copied to clipboard
Link copied to clipboard
fun <K, V> Option<Pair<K, V>>.toMap(): Map<K, V>
Link copied to clipboard
fun <A, B> Option<Ior<A, B>>.unalign(): Pair<Option<A>, Option<B>>
inline fun <A, B, C> Option<C>.unalign(f: (C) -> Ior<A, B>): Pair<Option<A>, Option<B>>
Link copied to clipboard
fun <A> Option<Iterable<A>>.unite(MA: Monoid<A>): Option<A>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun <A, B> Option<Pair<A, B>>.unzip(): Pair<Option<A>, Option<B>>
inline fun <A, B, C> Option<C>.unzip(f: (C) -> Pair<A, B>): Pair<Option<A>, Option<B>>
Link copied to clipboard
fun <B, A : B> Option<A>.widen(): Option<B>

Given A is a sub type of B, re-type this value from Option to Option