NullableExtensions Class

DECLARATION
public static class NullableExtensions
NAMESPACE
LanguageExt

Methods

Append<SEMI, T>(T?, T?)
SUMMARY

Append the Some(x) of one option to the Some(y) of another. For numeric values the behaviour is to sum the Somes (lhs + rhs) For string values the behaviour is to concatenate the strings For Lst/Stck/Que values the behaviour is to concatenate the lists For Map or Set values the behaviour is to merge the sets Otherwise if the T type derives from IAppendable then the behaviour is to call lhs.Append(rhs);

PARAMETERS
lhs
T?
Left-hand side of the operation
rhs
T?
Right-hand side of the operation
DECLARATION
[Pure]
public static T? Append<SEMI, T>(this T? lhs, T? rhs)
RETURNS
T?
lhs + rhs
CONSTRAINTS
where SEMI : struct Semigroup<T>
where T : struct
AsEnumerable<T>(T?)
SUMMARY

Convert NullableT to IEnumerableT (0..1 entries)

PARAMETERS
self
T?
Value to convert
DECLARATION
[Pure]
public static Seq<T> AsEnumerable<T>(this T? self)
RETURNS
Seq<T>
Zero or One enumerable values, depending on HasValue
CONSTRAINTS
where T : struct
Bind<T, R>(T?, Func<T, R?>)
PARAMETERS
self
T?
binder
Func<T, R?>
DECLARATION
[Pure]
public static R? Bind<T, R>(this T? self, Func<T, R?> binder)
RETURNS
R?
CONSTRAINTS
where T : struct
where R : struct
Bind<T, R>(T?, Func<T, R?>, Func<R?>)
PARAMETERS
self
T?
Some
Func<T, R?>
None
Func<R?>
DECLARATION
[Pure]
public static R? Bind<T, R>(this T? self, Func<T, R?> Some, Func<R?> None)
RETURNS
R?
CONSTRAINTS
where T : struct
where R : struct
Count<T>(T?)
SUMMARY

Returns 1 if there is a value, 0 otherwise

PARAMETERS
self
T?
DECLARATION
[Pure]
public static int Count<T>(this T? self)
RETURNS
int
1 if there is a value, 0 otherwise
CONSTRAINTS
where T : struct
Divide<NUM, T>(T?, T?)
SUMMARY

Divide the Somes. For numeric values the behaviour is to divide the Somes (lhs / rhs) For Lst values the behaviour is to divide all combinations of values in both lists to produce a new list Otherwise if the T type derives from IDivisible then the behaviour is to call lhs.Divide(rhs);

PARAMETERS
lhs
T?
Left-hand side of the operation
rhs
T?
Right-hand side of the operation
DECLARATION
[Pure]
public static T? Divide<NUM, T>(this T? lhs, T? rhs)
RETURNS
T?
lhs / rhs
CONSTRAINTS
where T : struct
where NUM : Num<T>
Exists<T>(T?, Func<T, bool>)
SUMMARY

Exists Nullable. Imagine the item has zero or one items depending on whether it's in a None state or not. This function runs a predicate against the value if it exists, returns false if it doesn't.

PARAMETERS
self
T?
pred
Func<T, bool>
Predicate
DECLARATION
[Pure]
public static bool Exists<T>(this T? self, Func<T, bool> pred)
RETURNS
bool
CONSTRAINTS
where T : struct
Exists<T>(T?, Func<T, bool>, Func<bool>)
SUMMARY

Exists Nullable. Imagine the item has zero or one items depending on whether it's in a None state or not. This function runs a predicate against the value if it exists, returns false if it doesn't.

PARAMETERS
self
T?
Some
Func<T, bool>
Some predicate
None
Func<bool>
None predicate
DECLARATION
[Pure]
public static bool Exists<T>(this T? self, Func<T, bool> Some, Func<bool> None)
RETURNS
bool
CONSTRAINTS
where T : struct
Filter<T>(T?, Func<T, bool>)
PARAMETERS
self
T?
pred
Func<T, bool>
DECLARATION
[Pure]
public static T? Filter<T>(this T? self, Func<T, bool> pred)
RETURNS
T?
CONSTRAINTS
where T : struct
Filter<T>(T?, Func<T, bool>, Func<bool>)
PARAMETERS
self
T?
Some
Func<T, bool>
None
Func<bool>
DECLARATION
[Pure]
public static T? Filter<T>(this T? self, Func<T, bool> Some, Func<bool> None)
RETURNS
T?
CONSTRAINTS
where T : struct
Fold<S, T>(T?, S, Func<S, T, S>)
SUMMARY

Folds Nullable into an S. https://en.wikipedia.org/wiki/Fold_(higher-order_function)

PARAMETERS
self
T?
state
S
Initial state
folder
Func<S, T, S>
Fold function
DECLARATION
[Pure]
public static S Fold<S, T>(this T? self, S state, Func<S, T, S> folder)
RETURNS
S
Folded state
CONSTRAINTS
where T : struct
Fold<S, T>(T?, S, Func<S, T, S>, Func<S, S>)
SUMMARY

Folds Nullable into an S. https://en.wikipedia.org/wiki/Fold_(higher-order_function)

PARAMETERS
self
T?
state
S
Initial state
Some
Func<S, T, S>
Fold function for Some
None
Func<S, S>
Fold function for None
DECLARATION
[Pure]
public static S Fold<S, T>(this T? self, S state, Func<S, T, S> Some, Func<S, S> None)
RETURNS
S
Folded state
CONSTRAINTS
where T : struct
ForAll<T>(T?, Func<T, bool>)
SUMMARY

ForAll Nullable. Imagine the item has zero or one items depending on whether it's in a None state or not. This function runs a predicate against the value if it exists, returns true if it doesn't (because the predicate holds 'for all' items).

PARAMETERS
self
T?
pred
Func<T, bool>
Predicate
DECLARATION
[Pure]
public static bool ForAll<T>(this T? self, Func<T, bool> pred)
RETURNS
bool
CONSTRAINTS
where T : struct
ForAll<T>(T?, Func<T, bool>, Func<bool>)
SUMMARY

ForAll Nullable. Imagine the item has zero or one items depending on whether it's in a None state or not. This function runs a predicate against the value if it exists, returns true if it doesn't (because the predicate holds 'for all' items).

PARAMETERS
self
T?
Some
Func<T, bool>
Some predicate
None
Func<bool>
None predicate
DECLARATION
[Pure]
public static bool ForAll<T>(this T? self, Func<T, bool> Some, Func<bool> None)
RETURNS
bool
CONSTRAINTS
where T : struct
IfNone<T>(T?, Func<T>)
PARAMETERS
self
T?
None
Func<T>
DECLARATION
[Pure]
public static T IfNone<T>(this T? self, Func<T> None)
RETURNS
T
CONSTRAINTS
where T : struct
IfNone<T>(T?, T)
PARAMETERS
self
T?
noneValue
T
DECLARATION
[Pure]
public static T IfNone<T>(this T? self, T noneValue)
RETURNS
T
CONSTRAINTS
where T : struct
IfSome<T>(T?, Action<T>)
SUMMARY

Invokes the someHandler if Nullable is in the Some state, otherwise nothing happens.

PARAMETERS
self
T?
someHandler
Action<T>
DECLARATION
public static Unit IfSome<T>(this T? self, Action<T> someHandler)
CONSTRAINTS
where T : struct
IfSome<T>(T?, Func<T, Unit>)
SUMMARY

Invokes the someHandler if Option is in the Some state, otherwise nothing happens.

PARAMETERS
self
T?
someHandler
Func<T, Unit>
DECLARATION
public static Unit IfSome<T>(this T? self, Func<T, Unit> someHandler)
CONSTRAINTS
where T : struct
Iter<T>(T?, Action<T>)
SUMMARY

Iterate Nullable. Imagine the item has zero or one items depending on whether it's in a None state or not.

PARAMETERS
self
T?
action
Action<T>
Action to invoke with the value if not in None state
DECLARATION
public static Unit Iter<T>(this T? self, Action<T> action)
CONSTRAINTS
where T : struct
Map<T, R>(T?, Func<T, R>)
PARAMETERS
self
T?
mapper
Func<T, R>
DECLARATION
[Pure]
public static R? Map<T, R>(this T? self, Func<T, R> mapper)
RETURNS
R?
CONSTRAINTS
where T : struct
where R : struct
Map<T, R>(T?, Func<T, R>, Func<R>)
PARAMETERS
self
T?
Some
Func<T, R>
None
Func<R>
DECLARATION
[Pure]
public static R? Map<T, R>(this T? self, Func<T, R> Some, Func<R> None)
RETURNS
R?
CONSTRAINTS
where T : struct
where R : struct
Match<T, R>(T?, Func<T, R>, Func<R>)
SUMMARY

Match the two states of the Nullable and return a non-null R.

PARAMETERS
self
T?
Some
Func<T, R>
Some handler
None
Func<R>
None handler
DECLARATION
[Pure]
public static R Match<T, R>(this T? self, Func<T, R> Some, Func<R> None)
RETURNS
R
A non-null R
CONSTRAINTS
where T : struct
Match<T>(T?, Action<T>, Action)
SUMMARY

Match the two states of the Nullable T

PARAMETERS
self
T?
Some
Action<T>
Some match
None
Action
None match
DECLARATION
public static Unit Match<T>(this T? self, Action<T> Some, Action None)
CONSTRAINTS
where T : struct
MatchAsync<T, R>(T?, Func<T, Task<R>>, Func<R>)
SUMMARY

Match the two states of the Nullable and return a promise for an R.

PARAMETERS
self
T?
Some
Func<T, Task<R>>
Some handler
None
Func<R>
None handler
DECLARATION
public static async Task<R> MatchAsync<T, R>(this T? self, Func<T, Task<R>> Some, Func<R> None)
RETURNS
Task<R>
A promise to return an R
CONSTRAINTS
where T : struct
MatchAsync<T, R>(T?, Func<T, Task<R>>, Func<Task<R>>)
SUMMARY

Match the two states of the Nullable and return a promise for an R.

PARAMETERS
self
T?
Some
Func<T, Task<R>>
Some handler
None
Func<Task<R>>
None handler
DECLARATION
public static async Task<R> MatchAsync<T, R>(this T? self, Func<T, Task<R>> Some, Func<Task<R>> None)
RETURNS
Task<R>
A promise to return an R
CONSTRAINTS
where T : struct
MatchObservable<T, R>(T?, Func<T, IObservable<R>>, Func<R>)
SUMMARY

Match the two states of the Nullable and return an observable stream of Rs.

PARAMETERS
self
T?
Some
Func<T, IObservable<R>>
Some handler
None
Func<R>
None handler
DECLARATION
[Pure]
public static IObservable<R> MatchObservable<T, R>(this T? self, Func<T, IObservable<R>> Some, Func<R> None)
RETURNS
IObservable<R>
A stream of Rs
CONSTRAINTS
where T : struct
MatchObservable<T, R>(T?, Func<T, IObservable<R>>, Func<IObservable<R>>)
SUMMARY

Match the two states of the Nullable and return an observable stream of Rs.

PARAMETERS
self
T?
Some
Func<T, IObservable<R>>
Some handler
None
Func<IObservable<R>>
None handler
DECLARATION
[Pure]
public static IObservable<R> MatchObservable<T, R>(this T? self, Func<T, IObservable<R>> Some, Func<IObservable<R>> None)
RETURNS
IObservable<R>
A stream of Rs
CONSTRAINTS
where T : struct
MatchObservable<T, R>(IObservable<T?>, Func<T, R>, Func<R>)
SUMMARY

Match the two states of the IObservable<Nullable<T>> and return a stream of non-null Rs.

PARAMETERS
self
IObservable<T?>
Some
Func<T, R>
Some handler
None
Func<R>
None handler
DECLARATION
[Pure]
public static IObservable<R> MatchObservable<T, R>(this IObservable<T?> self, Func<T, R> Some, Func<R> None)
RETURNS
IObservable<R>
A stream of Rs
CONSTRAINTS
where T : struct
Plus<NUM, T>(T?, T?)
SUMMARY

Sum the Some(x) of one nullable from the Some(y) of another. For numeric values the behaviour is to find the subtract between the Somes (lhs - rhs) For Lst values the behaviour is to remove items in the rhs from the lhs For Map or Set values the behaviour is to remove items in the rhs from the lhs Otherwise if the T type derives from ISubtractable then the behaviour is to call lhs.Plus(rhs);

PARAMETERS
lhs
T?
Left-hand side of the operation
rhs
T?
Right-hand side of the operation
DECLARATION
[Pure]
public static T? Plus<NUM, T>(this T? lhs, T? rhs)
RETURNS
T?
lhs - rhs
CONSTRAINTS
where T : struct
where NUM : Num<T>
Product<NUM, T>(T?, T?)
SUMMARY

Find the product of the Somes. For numeric values the behaviour is to multiply the Somes (lhs * rhs) For Lst values the behaviour is to multiply all combinations of values in both lists to produce a new list Otherwise if the T type derives from IMultiplicable then the behaviour is to call lhs.Product(rhs);

PARAMETERS
lhs
T?
Left-hand side of the operation
rhs
T?
Right-hand side of the operation
DECLARATION
[Pure]
public static T? Product<NUM, T>(this T? lhs, T? rhs)
RETURNS
T?
lhs * rhs
CONSTRAINTS
where T : struct
where NUM : Num<T>
Select<T, U>(T?, Func<T, U>)
PARAMETERS
self
T?
map
Func<T, U>
DECLARATION
[Pure]
[EditorBrowsable(EditorBrowsableState.Never)]
public static U? Select<T, U>(this T? self, Func<T, U> map)
RETURNS
U?
CONSTRAINTS
where T : struct
where U : struct
SelectMany<T, U, V>(T?, Func<T, U?>, Func<T, U, V>)
PARAMETERS
self
T?
bind
Func<T, U?>
project
Func<T, U, V>
DECLARATION
[Pure]
[EditorBrowsable(EditorBrowsableState.Never)]
public static V? SelectMany<T, U, V>(this T? self, Func<T, U?> bind, Func<T, U, V> project)
RETURNS
V?
CONSTRAINTS
where T : struct
where U : struct
where V : struct
Somes<T>(IEnumerable<T?>)
SUMMARY

Extracts from a list of nullables all the HasValue elements. All the 'Some' elements are extracted in order.

PARAMETERS
self
IEnumerable<T?>
DECLARATION
[Pure]
public static IEnumerable<T> Somes<T>(this IEnumerable<T?> self)
RETURNS
IEnumerable<T>
CONSTRAINTS
where T : struct
Subtract<NUM, T>(T?, T?)
SUMMARY

Subtract the Some(x) of one nullable from the Some(y) of another. For numeric values the behaviour is to find the subtract between the Somes (lhs - rhs) For Lst values the behaviour is to remove items in the rhs from the lhs For Map or Set values the behaviour is to remove items in the rhs from the lhs Otherwise if the T type derives from ISubtractable then the behaviour is to call lhs.Subtract(rhs);

PARAMETERS
lhs
T?
Left-hand side of the operation
rhs
T?
Right-hand side of the operation
DECLARATION
[Pure]
public static T? Subtract<NUM, T>(this T? lhs, T? rhs)
RETURNS
T?
lhs - rhs
CONSTRAINTS
where T : struct
where NUM : Num<T>
Sum(int?)
PARAMETERS
self
int?
DECLARATION
[Pure]
public static int Sum(this int? self)
RETURNS
int
ToArray<T>(T?)
PARAMETERS
self
T?
DECLARATION
[Pure]
public static Arr<T> ToArray<T>(this T? self)
RETURNS
Arr<T>
CONSTRAINTS
where T : struct
ToEither<L, T>(T?, L)
PARAMETERS
self
T?
defaultLeftValue
L
DECLARATION
[Pure]
public static Either<L, T> ToEither<L, T>(this T? self, L defaultLeftValue)
RETURNS
Either<L, T>
CONSTRAINTS
where T : struct
ToEither<L, T>(T?, Func<L>)
PARAMETERS
self
T?
Left
Func<L>
DECLARATION
[Pure]
public static Either<L, T> ToEither<L, T>(this T? self, Func<L> Left)
RETURNS
Either<L, T>
CONSTRAINTS
where T : struct
ToEitherUnsafe<L, T>(T?, L)
PARAMETERS
self
T?
defaultLeftValue
L
DECLARATION
[Pure]
public static EitherUnsafe<L, T> ToEitherUnsafe<L, T>(this T? self, L defaultLeftValue)
RETURNS
EitherUnsafe<L, T>
CONSTRAINTS
where T : struct
ToEitherUnsafe<L, T>(T?, Func<L>)
PARAMETERS
self
T?
Left
Func<L>
DECLARATION
[Pure]
public static EitherUnsafe<L, T> ToEitherUnsafe<L, T>(this T? self, Func<L> Left)
RETURNS
EitherUnsafe<L, T>
CONSTRAINTS
where T : struct
ToList<T>(T?)
PARAMETERS
self
T?
DECLARATION
[Pure]
public static Lst<T> ToList<T>(this T? self)
RETURNS
Lst<T>
CONSTRAINTS
where T : struct
ToOption<T>(T?)
SUMMARY

Convert NullableT to OptionT

PARAMETERS
self
T?
Value to convert
DECLARATION
[Pure]
public static Option<T> ToOption<T>(this T? self)
RETURNS
Option<T>
OptionT with Some or None, depending on HasValue
CONSTRAINTS
where T : struct
ToSeq<A>(A?)
SUMMARY

Convert Nullable to Seq (0..1 entries)

PARAMETERS
self
A?
Value to convert
DECLARATION
[Pure]
public static Seq<A> ToSeq<A>(this A? self)
RETURNS
Seq<A>
Zero or One values, depending on HasValue
CONSTRAINTS
where A : struct
ToTryOption<L, T>(T?, L)
PARAMETERS
self
T?
defaultLeftValue
L
DECLARATION
[Pure]
public static TryOption<T> ToTryOption<L, T>(this T? self, L defaultLeftValue)
RETURNS
TryOption<T>
CONSTRAINTS
where T : struct
Where<T>(T?, Func<T, bool>)
PARAMETERS
self
T?
pred
Func<T, bool>
DECLARATION
[Pure]
[EditorBrowsable(EditorBrowsableState.Never)]
public static T? Where<T>(this T? self, Func<T, bool> pred)
RETURNS
T?
CONSTRAINTS
where T : struct