Table of Contents

Class MaybeExtensionMethods

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

The operations available on a Maybe<T> and on sequences of them.

[PublicAPI]
public static class MaybeExtensionMethods
Inheritance
MaybeExtensionMethods
Inherited Members

Methods

AllSomeOrNone<T>(IEnumerable<Maybe<T>>?)

Turns a sequence of values that can be missing into a sequence that can be missing, which has a value only when each entry was.

AllSomeOrNone<T, TResult>(IEnumerable<T>?, Func<T, Maybe<TResult>>)

Applies a function which can give no value to each element of a sequence, and collects the results only when each one has a value.

Flatten<T>(Maybe<Maybe<T>>)

Collapses a nested Maybe<T> into a single one.

Lift<T1, T2, TResult>(Maybe<T1>, Maybe<T2>, Func<T1, T2, TResult>)

Lift a binary function into values that can be missing, so the result has a value only when the two inputs were.

Lift<T1, T2, T3, TResult>(Maybe<T1>, Maybe<T2>, Maybe<T3>, Func<T1, T2, T3, TResult>)

Lift a ternary function into values that can be missing, so the result has a value only when all three inputs were.

Lift<T1, T2, T3, T4, TResult>(Maybe<T1>, Maybe<T2>, Maybe<T3>, Maybe<T4>, Func<T1, T2, T3, T4, TResult>)

Lift a quaternary function into values that can be missing, so the result has a value only when all four inputs were.

OrElse<T>(Maybe<T>, Maybe<T>)

Returns this value if it has one, and the given value otherwise.

OrElse<T>(Maybe<T>, Func<Maybe<T>>)

Returns this value if it has one, and the result of the given function otherwise.

ToEnumerable<T>(Maybe<T>)

Views a Maybe<T> as a sequence of one element, or of no elements.

ToMaybe<T>(T?)

Changes a Nullable<T> into a Maybe<T>.

ToMaybe<T>(T?)

Changes a reference which can be null into a Maybe<T>.

ToNullable<T>(Maybe<T>)

Changes a Maybe<T> of a value type into a Nullable<T>.

ValueOrDefault<T>(Maybe<T>)

Returns the contained value if there is one, and the default for its type otherwise.

ValueOrThrow<T>(Maybe<T>, Func<Exception>)

Returns the contained value if there is one, and throws the exception produced by the given function otherwise.

ValueOr<T>(Maybe<T>, Func<T>)

Returns the contained value if there is one, and the result of the given function otherwise.

ValueOr<T>(Maybe<T>, T)

Returns the contained value if there is one, and the given value otherwise.

WhereSome<T>(IEnumerable<Maybe<T>>?)

Returns the values from a sequence which have one, discarding the entries which do not.