View source

class thx.Options

Available on all platforms

Extension methods for the haxe.ds.Option type.

Class Fields

static function all<T>(option:Option<T>, f:T -> Bool):Bool

static function any<T>(option:Option<T>, f:T -> Bool):Bool

static function ap<T, U>(option:Option<T>, fopt:Option<T -> U>):Option<U>

ap transforms a value contained in Option<T> to Option<TOut> using a callback wrapped in another Option.

static inline function ap2<X, A, B, C>(f:A -> B -> C, v1:Option<A>, v2:Option<B>):Option<C>

static inline function ap3<X, A, B, C, D>(f:A -> B -> C -> D, v1:Option<A>, v2:Option<B>, v3:Option<C>):Option<D>

static inline function ap4<X, A, B, C, D, E>(f:A -> B -> C -> D -> E, v1:Option<A>, v2:Option<B>, v3:Option<C>, v4:Option<D>):Option<E>

static inline function ap5<X, A, B, C, D, E, F>(f:A -> B -> C -> D -> E -> F, v1:Option<A>, v2:Option<B>, v3:Option<C>, v4:Option<D>, v5:Option<E>):Option<F>

static inline function ap6<X, A, B, C, D, E, F, G>(f:A -> B -> C -> D -> E -> F -> G, v1:Option<A>, v2:Option<B>, v3:Option<C>, v4:Option<D>, v5:Option<E>, v6:Option<F>):Option<G>

static inline function ap7<X, A, B, C, D, E, F, G, H>(f:A -> B -> C -> D -> E -> F -> G -> H, v1:Option<A>, v2:Option<B>, v3:Option<C>, v4:Option<D>, v5:Option<E>, v6:Option<F>, v7:Option<G>):Option<H>

static inline function ap8<X, A, B, C, D, E, F, G, H, I>(f:A -> B -> C -> D -> E -> F -> G -> H -> I, v1:Option<A>, v2:Option<B>, v3:Option<C>, v4:Option<D>, v5:Option<E>, v6:Option<F>, v7:Option<G>, v8:Option<H>):Option<I>

static function equals<T>(a:Option<T>, b:Option<T>, ?eq:T -> T -> Bool):Bool

Equality function to campare two Option values of the same type. An optional equality function can be provided if values inside Some should be compared using something different than strict equality.

static function equalsValue<T>(a:Option<T>, b:Null<T>, ?eq:T -> T -> Bool):Bool

equalsValue compares an Option<T> with a value T. The logic adopted to compare values is the same as in Options.equals().

static function flatMap<T, TOut>(option:Option<T>, callback:T -> Option<TOut>):Option<TOut>

flatMap is shortcut for map(cb).join()

static function foldLeft<T, B>(option:Option<T>, b:B, f:B -> T -> B):B

foldLeft reduce using an accumulating function and an initial value.

static function get<T>(option:Option<T>):Null<T>

toValue extracts the value from Option. If the Option is None, null is returned.

static function getOrElse<T>(option:Option<T>, alt:T):T

getOrElse extracts the value from Option. If the Option is None, alt value is returned.

static function join<T>(option:Option<Option<T>>):Option<T>

join collapses a nested option into a single optional value.

static function map<T, TOut>(option:Option<T>, callback:T -> TOut):Option<TOut>

map transforms a value contained in Option<T> to Option<TOut> using a callback. callback is used only if Option is Some(value).

static inline function ofValue<T>(value:Null<T>):Option<T>

static function orElse<T>(option:Option<T>, alt:Option<T>):Option<T>

orElse returns option if it holds a value or alt otherwise.

static function toArray<T>(option:Option<T>):Array<T>

toArray transforms an Option<T> value into an Array<T> value. The result array will be empty if Option is None or will contain one value otherwise.

static function toBool<T>(option:Option<T>):Bool

toBool transforms an Option value into a boolean: None maps to false, and Some(_) to true. The value in Some has no play in the conversion.

static inline function toOption<T>(value:Null<T>):Option<T>

toOption transforms any type T into Option<T>. If the value is null, the result is be None.

static function toSuccess<E, T>(option:Option<T>, error:E):Validation<E, T>

static function toSuccessNel<E, T>(option:Option<T>, error:E):VNel<E, T>

Toggle inherited fields