Limited ahd experimental for now; waiting for generics in operator overloading to be actually useful.
Returns the error when IsErr; map(Unwrap()) when IsOk flattenning the result. Shorthand combining Map and Flatten calls.static Res<Team> TryGetTeam() { .. } // tries to grab a team; might fail, hence, returns Res.
static Res TryPutTeam(Team team) { .. } // tries to put the team; might fail, hence, returns Res.
Res result = TryGetTeam().FlatMap(TryPutTeam);
// equivalently:
Res result = TryGetTeam().FlatMap(team => TryPutTeam(team));
// this is a shorthand for:
Res result = TryGetTeam() // Res<Team>
.Map(TryPutTeam) // Res<Res>
.Flatten(); // Res
public static Res operator |(
Res<T> result,
Func<T, Res> map
)