sparse-intern-71089
01/12/2022, 12:12 PMechoing-dinner-19531
01/12/2022, 12:37 PMinput.Apply(union => union.Bimap(t0 => (U0)t0, t1 => (U1)t1));
As that doesn't exist yet you can use TryPick to get long hand version:
input.Apply(union => {
if (union.TryPickT0(out var t0, out var t1)) {
return Union<U0, U1>.FromT0((U0)t0);
} else {
return Union<U0, U1>.FromT0((U1)t1);
}
});
echoing-dinner-19531
01/12/2022, 12:44 PMinput.Apply(union => union.Match<Union<TResult0, TResult1>>(t0 => mapFunc0(t0), t1 => mapFunc1(t1)))
But a bimap function would be shorter and save those type annotations probably.
Wonder if we should lift some of these methods to be directly on InputUnion as wellthousands-jordan-32051
01/12/2022, 2:32 PMthousands-jordan-32051
01/12/2022, 2:35 PMechoing-dinner-19531
01/12/2022, 5:49 PMechoing-dinner-19531
01/12/2022, 6:16 PMthousands-jordan-32051
01/13/2022, 9:48 AM