Optional
Optional copied to clipboard
Map Exception and inner value
In the following code
IEnumerable<(A, Option<B, Exception>)> result = aValues
.Select(a => (a, a.ComputeB())
I wish to transform the value (A, Option<B, Exception>)
to Option<(A, B), (A, Exception)>
.
For this operation a Map
operation that transforms both, the inner value or the exception value is missing. It is only possible to specify one mapper instead of a mapper for both cases.
Any reason a chained .Map(...).MapException(...)
wouldn't do? My initial thought is that it seems a bit too much of an edge case to have a dedicated method for the purpose.
Actually, that would work. I wonder if it is really such an edge case.
As I didn't recognize that solution immediately, I have already created an extended Map
function. Feel free to merge or reject it.