Table of Contents

Interface IMaybe

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

A non-generic view of a Maybe<T>. Use it in code that must handle a value that is there, or that has none, with no knowledge of its type.

[PublicAPI]
public interface IMaybe
Extension Methods

Remarks

Each member mirrors one on Maybe<T>, with the contained value surfaced as object. Prefer Maybe<T> itself wherever the type is known: this interface boxes, and loses the type of the value.

Methods

MatchAsyncVoid(Func<object?, Task>, Func<Task>)

Runs one asynchronous action when there is a value, and a different one when there is none.

MatchAsync<T>(Func<object?, Task<T>>, Func<Task<T>>)

Runs one asynchronous function when there is a value, and a different one when there is none, and gives the result.

MatchNone(Action)

Runs an action when there is no value, and otherwise does nothing.

MatchNoneAsync(Func<Task>)

Runs an asynchronous action when there is no value, and otherwise does nothing.

MatchSome(Action<object?>)

Runs an action with the contained value when there is one, and otherwise does nothing.

MatchSomeAsync(Func<object?, Task>)

Runs an asynchronous action with the contained value when there is one, and otherwise does nothing.

MatchVoid(Action<object?>, Action)

Runs one action when there is a value, and a different action when there is none.

Match<T>(Func<object?, T>, Func<T>)

Runs one function when there is a value, and a different one when there is none.