Limited ahd experimental for now; waiting for generics in operator overloading to be actually useful.
Returns the error when IsErr; map() when IsOk, flattenning the result. This is a shorthand for sequential Map and Flatten calls.// assume we have two methods that can fail; hence returns a Res:
static Res TryRunRiskyOperation() { .. }
static Res TryLogCompletion() { .. }
// we want to call both operations; but the second one only if the first one succeeds.
Res result = TryRunRiskyOperation().FlatMap(TryLogCompletion);
// alternatively:
Res result = TryRunRiskyOperation().FlatMap(() => TryLogCompletion());
// this is equivalent to:
Res result = TryRunRiskyOperation().Map(() => TryLogCompletion()/*Res<Res>*/).Flatten()/*Res*/;
public static Res operator |(
Res result,
Func<Res> map
)