Extension methods for the haxe.ds.Option type.

Static methods

staticall<T>(option:Option<T>, f:T ‑> Bool):Bool

staticinlinealt2<A>(a:Option<A>, b:Option<A>):Option<A>

Returns the first Some value, or None Alias for orElse, but intended for static use, and leads into alt3, alt4, alts, etc.

staticinlinealt3<A>(a:Option<A>, b:Option<A>, c:Option<A>):Option<A>

Returns the first Some value, or None

staticinlinealt4<A>(a:Option<A>, b:Option<A>, c:Option<A>, d:Option<A>):Option<A>

Returns the first Some value, or None

staticalts<A>(as:ReadonlyArray<Option<A>>):Option<A>

Returns the first Some value, or None

staticaltsF<A>(fs:ReadonlyArray<() ‑> Option<A>>):Option<A>

Returns the result of the first function that produces a Some value, or None

staticany<T>(option:Option<T>, f:T ‑> Bool):Bool

staticap<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.

staticinlineap2<A, B, C>(f:(A, B) ‑> C, v1:Option<A>, v2:Option<B>):Option<C>

staticinlineap3<A, B, C, D>(f:(A, B, C) ‑> D, v1:Option<A>, v2:Option<B>, v3:Option<C>):Option<D>

staticinlineap4<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>

staticinlineap5<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>

staticinlineap6<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>

staticinlineap7<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>

staticinlineap8<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>

staticcata<A, B>(option:Option<A>, ifNone:B, f:A ‑> B):B

cata the option catamorphism, useful for inline deconstruction.

staticcataf<A, B>(option:Option<A>, ifNone:() ‑> B, f:A ‑> B):B

Lazy version of thx.Options.cata

staticinlinecombine<A, B>(a:Option<A>, b:Option<B>):Option<Tuple2<A, B>>

staticinlinecombine2<A, B>(a:Option<A>, b:Option<B>):Option<Tuple2<A, B>>

staticinlinecombine3<A, B, C>(a:Option<A>, b:Option<B>, c:Option<C>):Option<Tuple3<A, B, C>>

staticinlinecombine4<A, B, C, D>(a:Option<A>, b:Option<B>, c:Option<C>, d:Option<D>):Option<Tuple4<A, B, C, D>>

staticinlinecombine5<A, B, C, D, E>(a:Option<A>, b:Option<B>, c:Option<C>, d:Option<D>, e:Option<E>):Option<Tuple5<A, B, C, D, E>>

staticinlinecombine6<A, B, C, D, E, F>(a:Option<A>, b:Option<B>, c:Option<C>, d:Option<D>, e:Option<E>, f:Option<F>):Option<Tuple6<A, B, C, D, E, F>>

staticeach<T>(o:Option<T>, f:T ‑> Void):Option<T>

Performs f on the contents of o if o != None

staticequals<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.

staticequalsValue<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().

staticfilter<A>(option:Option<A>, f:A ‑> Bool):Option<A>

filter returns the current value if any contained value matches the predicate, None otherwise.

staticflatMap<T, TOut>(option:Option<T>, callback:T ‑> Option<TOut>):Option<TOut>

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

staticfoldLeft<T, B>(option:Option<T>, b:B, f:(B, T) ‑> B):B

foldLeft reduce using an accumulating function and an initial value.

staticfoldLeftf<T, B>(option:Option<T>, b:() ‑> B, f:(B, T) ‑> B):B

Lazy version of thx.Options.foldLeft

staticfoldMap<A, B>(option:Option<A>, f:A ‑> B, m:Monoid<B>):B

Fold by mapping the contained value into some monoidal type and reducing with that monoid.

staticget<T>(option:Option<T>):Null<T>

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

staticgetOrElse<T>(option:Option<T>, alt:T):T

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

staticgetOrElseF<T>(option:Option<T>, alt:() ‑> T):T

getOrElseF extracts the value from Option. If the Option is None, alt function is called to produce a default value..

staticgetOrFail<T>(option:Option<T>, msg:String, ?posInfo:PosInfos):T

Extract the value from Option or throw a thx.Error with the provided message.

staticgetOrThrow<T>(option:Option<T>, ?err:Error, ?posInfo:PosInfos):T

Extract the value from Option or throw a thx.Error if the Option is None.

staticisNone<T>(option:Option<T>):Bool

isNone determines whether the option is a None

staticjoin<T>(option:Option<Option<T>>):Option<T>

join collapses a nested option into a single optional value.

staticmap<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).

staticinlinemaybe<T>(value:Null<T>):Option<T>

staticinlineofValue<T>(value:Null<T>):Option<T>

staticorElse<T>(option:Option<T>, alt:Option<T>):Option<T>

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

staticorElseF<T>(option:Option<T>, alt:() ‑> Option<T>):Option<T>

orElseF returns option if it holds a value or calls alt to produce a default Option<T>.

staticinlinespread<A, B, C>(v:Option<Tuple2<A, B>>, f:(A, B) ‑> C):Option<C>

staticinlinespread2<A, B, C>(v:Option<Tuple2<A, B>>, f:(A, B) ‑> C):Option<C>

staticinlinespread3<A, B, C, D>(v:Option<Tuple3<A, B, C>>, f:(A, B, C) ‑> D):Option<D>

staticinlinespread4<A, B, C, D, E>(v:Option<Tuple4<A, B, C, D>>, f:(A, B, C, D) ‑> E):Option<E>

staticinlinespread5<A, B, C, D, E, F>(v:Option<Tuple5<A, B, C, D, E>>, f:(A, B, C, D, E) ‑> F):Option<F>

staticinlinespread6<A, B, C, D, E, F, G>(v:Option<Tuple6<A, B, C, D, E, F>>, f:(A, B, C, D, E, F) ‑> G):Option<G>

statictoArray<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.

statictoBool<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.

statictoFailure<E, T>(error:Option<E>, value:T):Validation<E, T>

statictoFailureNel<E, T>(error:Option<E>, value:T):VNel<E, T>

statictoLazyRight<E, T>(opt:Option<T>, left:() ‑> E):Either<E, T>

statictoLazySuccess<E, T>(option:Option<T>, error:() ‑> E):Validation<E, T>

statictoLazySuccessNel<E, T>(option:Option<T>, error:() ‑> E):VNel<E, T>

statictoLeft<E, T>(opt:Option<E>, right:T):Either<E, T>

staticinlinetoOption<T>(value:Null<T>):Option<T>

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

statictoRight<E, T>(opt:Option<T>, left:E):Either<E, T>

statictoSuccess<E, T>(option:Option<T>, error:E):Validation<E, T>

statictoSuccessNel<E, T>(option:Option<T>, error:E):VNel<E, T>

statictraverseValidation<E, T, U>(option:Option<T>, f:T ‑> Validation<E, U>):Validation<E, Option<U>>

Traverse the array with a function that may return values wrapped in Validation. If any of the values are Failures, return a Failure that accumulates all errors from the failed values, otherwise return the array of mapped values in a Success.