We postpone generalizing most of the higher-order functions that make
Resultconvenient to use, as we currently lack the means to reason about lifetime dependencies for such functions. But we are already able to generalize the two functions that do not have complicated lifetime semantics:mapErrorandflatMapError.
The transform closure of the flatMapError method can return a new Success value:
let f: Result<Int, any Error> = .failure(CancellationError())
let s: Result<Int, any Error> = f.flatMapError { _ in .success(42) }
Therefore flatMapError might have the same issue as flatMap and map.