public static ThunkAsync <B> MapAsync <A, B>(this Thunk <A> ma, Func <A, ValueTask <B> > f) => ThunkAsync <B> .Lazy(async() => { var ra = ma.Value(); if (ra.IsSucc) { return(FinSucc(await f(ra.Value).ConfigureAwait(false))); } else { return(FinFail <B>(ra.Error)); } });
public static ThunkAsync <Env, B> MapAsync <Env, A, B>(this Thunk <A> ma, Func <A, ValueTask <B> > f) where Env : struct, HasCancel <Env> => ThunkAsync <Env, B> .Lazy(async env => { var ra = ma.Value(); if (ra.IsSucc) { return(FinSucc(await f(ra.Value).ConfigureAwait(false))); } else { return(FinFail <B>(ra.Error)); } });
internal Aff(ThunkAsync <A> thunk) => this.thunk = thunk ?? throw new ArgumentNullException(nameof(thunk));
public static Aff <OuterRT, A> localAff <OuterRT, InnerRT, A>(Func <OuterRT, InnerRT> f, Aff <InnerRT, A> ma) where OuterRT : struct, HasCancel <OuterRT> where InnerRT : struct, HasCancel <InnerRT> => new Aff <OuterRT, A>(ThunkAsync <OuterRT, A> .Lazy(oenv => ma.Thunk.Value(f(oenv))));