Table of Contents

Method BindAsync

Namespace
SodaFlow.Functional
Assembly
SodaFlow.Functional.dll

BindAsync<T, TResult>(Maybe<T>, Func<T, Task<Maybe<TResult>>>)

Transforms the contained value into a second Maybe<T> with an asynchronous function, if there is one, flattening the result.

public static Task<Maybe<TResult>> BindAsync<T, TResult>(this Maybe<T> a, Func<T, Task<Maybe<TResult>>> f)

Parameters

a Maybe<T>

The value to transform.

f Func<T, Task<Maybe<TResult>>>

Run with the contained value when there is one.

Returns

Task<Maybe<TResult>>

The task returned by f if a contained a value, and a completed task giving no value otherwise.

Type Parameters

T

The type of the value, when there is one.

TResult

The type of the value the function produces.

Remarks

The asynchronous Bind<T, TResult>(Maybe<T>, Func<T, Maybe<TResult>>), for the lookup which is itself asynchronous and can find nothing. When there is a value the task returned is the one f returned, not a wrapper around it, so a failure surfaces as that task faulting.

BindAsync<T, TResult>(Task<Maybe<T>>, Func<T, Task<Maybe<TResult>>>)

Transforms the value the task will give into a second Maybe<T> with an asynchronous function, if it gives one, flattening the result.

public static Task<Maybe<TResult>> BindAsync<T, TResult>(this Task<Maybe<T>> a, Func<T, Task<Maybe<TResult>>> f)

Parameters

a Task<Maybe<T>>

The task giving the value to transform.

f Func<T, Task<Maybe<TResult>>>

Run with the contained value when there is one.

Returns

Task<Maybe<TResult>>

A task giving the result of f if the awaited value contained a value, and a Maybe<T> containing no value otherwise.

Type Parameters

T

The type of the value, when there is one.

TResult

The type of the value the function produces.