public static Task <Option <TResult> > SelectMany <TValue, TBind, TResult>(this Option <TValue> option, Func <TValue, Task <Option <TBind> > > bind, Func <TValue, TBind, Task <TResult> > resultSelector) { if (bind == null) { throw new ArgumentNullException(nameof(bind)); } if (resultSelector == null) { throw new ArgumentNullException(nameof(resultSelector)); } return(option.BindAsync(value => bind .Invoke(value) .SelectAsync(obj => resultSelector.Invoke(value, obj)) )); }
public static Task <Option <TValue> > Where <TValue>(this Option <TValue> source, Func <TValue, Task <Option <Unit> > > failurePredicate) => source .BindAsync(success => failurePredicate .Invoke(success) .Select(_ => success) );