// applicative public static Exceptional <R> Apply <T, R> (this Exceptional <Func <T, R> > @this, Exceptional <T> arg) => @this.Match( Exception: ex => ex, Success: func => arg.Match( Exception: ex => ex, Success: t => new Exceptional <R>(func(t))));
public static Exceptional <RR> SelectMany <T, R, RR>(this Exceptional <T> @this , Func <T, Exceptional <R> > bind, Func <T, R, RR> project) { if (@this.Exception) { return(new Exceptional <RR>(@this.Ex)); } var bound = bind(@this.Value); return(bound.Exception ? new Exceptional <RR>(bound.Ex) : project(@this.Value, bound.Value)); }
// LINQ public static Exceptional <R> Select <T, R>(this Exceptional <T> @this , Func <T, R> map) => @this.Map(map);
public static Exceptional <RR> Bind <R, RR>(this Exceptional <R> @this , Func <R, Exceptional <RR> > func) => @this.Success ? func(@this.Value) : new Exceptional <RR>(@this.Ex);