[Accepted with Modifications] SE-0235: Add Result to the Standard Library

But with this operation we are mapping a concrete type for Failure, not the Error type (even though it's now possible with self-constrained Error protocol). I don't think mapError and flatMapError is justified after the change from Error to Failure even if it conforms to Error. Furthermore the new Result contains a NewFailure not a NewError.

There is no concrete Failure type as in Swift.Failure . The generic type Failure is ultimately going to be a Swift.Error. This allows us to ” have our cake and eat it too”. The fact that the cases have the same name as their generic type is unfortunate but arguably better than T and E. There would not be a suggestion to call it .mapE If E happened to be the name of the Failure generic type.

I would agree with your argument if the generic type Failure was not constrained to Swift.Error

6 Likes