option library

Classes

None<A>
Represents the absence of a value. It's a concrete implementation of Option.
Option<A>
Represents an optional value: every instance is either Some, containing a value, or None, indicating the absence of a value. This pattern is an alternative to using nullable types (null) for representing the absence of a value.
OptionEq<A>
Defines equality for instances of Option.
OptionOrd<A>
Provides an ordering for Option<A> based on an existing ordering for A.
Some<A>
Represents an existing value of type A. It's a concrete implementation of Option.

Properties

chain Option<B> Function(Option<A>) Function<A, B>(Option<B> f(A))
Alias for flatMap.
final
chainFirst TapFunction<A> Function<A>(void f(A))
Alias for tap.
final
fold → B Function(Option<A>) Function<A, B>(B onNone(), B onSome(A))
Alias for match.
final
some Option<B> Function<B>(B value)
An alias for of, used to wrap the given value.
final

Functions

ap<A, B>(Option<B Function(A)> fOpt) Option<B> Function(Option<A>)
Applies a function wrapped in an Option to a value also wrapped in an Option.
flatMap<A, B>(Option<B> f(A)) Option<B> Function(Option<A>)
Transforms the value inside an Option using a function that returns an Option.
fromNullable<A>(A? value) Option<A>
Returns an Option from a nullable value.
fromPredicate<A>(Predicate<A> predicate, A value) Option<A>
Returns an Option based on the evaluation of a Predicate on a value.
getEq<A>(Eq<A> eq) Eq<Option<A>>
Returns an Eq for Option<A>, given an Eq<A>.
getOrd<A>(Ord<A> ord) Ord<Option<A>>
Returns an Ord<Option<A>> based on the provided Ord<A>.
getOrElse<A>(A defaultFunction()) → A Function(Option<A>)
Returns a function that, when provided with an Option<A>, will yield the value inside if it's a Some, or the result of the defaultFunction if it's a None.
map<A, B>(B f(A)) Option<B> Function(Option<A> p1)
Transforms the value inside an Option using a given function.
match<A, B>(B onNone(), B onSome(A)) → B Function(Option<A>)
A pattern matching function for Option that provides branching based on the content of the Option.
matchW<A, B, C>(C onNone(), C onSome(A)) → C Function(Option<A>)
A more generalized match function for Option that returns a value of a potentially different type.
of<B>(B value) Option<B>
Wraps the given value in a Some, indicating the presence of a value.
sequenceList<A>(ImmutableList<Option<A>> list) Option<ImmutableList<A>>
Takes an ImmutableList of Option values and returns an Option containing an ImmutableList of values.
tap<A>(void f(A)) TapFunction<A>
Curries the tap function by taking a side effect function f. It returns a specialized version of the tap function that can be used to apply the side effect on an Option<A> instance directly without specifying the side effect function again.
traverseList<A, B>(Option<B> fn(A)) Option<ImmutableList<B>> Function(ImmutableList<A>)
Takes an ImmutableList and a function, then applies the function to each item in the list.

Typedefs

TapFunction<A> = Option<A> Function(Option<A> option)
The tap function takes a side effect function Function that is applied to the value inside the Some instance of Option. It returns the original Option after performing the side effect on the value. If the input Option is None, the function simply returns the same None.