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
aMaybe<T>The value to transform.
fFunc<T, Task<Maybe<TResult>>>Run with the contained value when there is one.
Returns
- Task<Maybe<TResult>>
The task returned by
fifacontained a value, and a completed task giving no value otherwise.
Type Parameters
TThe type of the value, when there is one.
TResultThe 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
aTask<Maybe<T>>The task giving the value to transform.
fFunc<T, Task<Maybe<TResult>>>Run with the contained value when there is one.
Returns
- Task<Maybe<TResult>>
A task giving the result of
fif the awaited value contained a value, and a Maybe<T> containing no value otherwise.
Type Parameters
TThe type of the value, when there is one.
TResultThe type of the value the function produces.