public static OptionAsync <A> ToAsync <A>(this Task <Option <A> > ma) => new OptionAsync <A>(OptionDataAsync.Lazy(async() => { var a = await ma; return(a.IsSome ? new Result <A>(a.Value) : Result <A> .None); }));
public OptionAsync <A> Return(Func <Unit, A> f) => new OptionAsync <A>(OptionDataAsync.Lazy(() => Task.Run(() => { var a = f(unit); return(a.IsNull() ? new Result <A>() : new Result <A>(a)); })));
public OptionAsync <B> BiMap(OptionAsync <A> ma, Func <A, B> fa, Func <Unit, B> fb) => new OptionAsync <B>(OptionDataAsync.Lazy <B>(async() => await ma.Match( Some: x => fa(x), None: () => fb(unit))));