Extension methods for the haxe.ds.Option type.

Static methods

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

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.

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

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

staticinline ap4<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>

staticinline ap5<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>

staticinline ap6<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>

staticinline ap7<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>

staticinline ap8<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:Void ‑> B, f:A ‑> B):B

Lazy version of thx.Options.cata

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

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

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

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

staticinline combine5<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>>

staticinline combine6<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:Void ‑> 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.

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

staticinline maybe<T> (value:Null<T>):Option<T>

staticinline ofValue<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.

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

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

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

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

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

staticinline spread6<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>

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

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

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.