I actually think mapError
is a better name than mapFailure
.
- The name is consistent with existing declarations like
Result.mapError
andCombine.Publisher.mapError
. - I think calling it
mapFailure
implies thatmap
should actually be calledmapSuccess
(which would obviously be a bad name). The namemapError
, on the other hand, implies that it's like themap
method, but for when an error occurs, which I think is a better explanation.
I also think we should directly return AsyncMapFailureSequence
rather than a some
type. If we only return some AsyncSequence<Element, MappedError>
, then the type system ignores the fact that AsyncMapFailureSequence
is conditionally Sendable
, which will make it more difficult to work with in async environments.
It might also be worth publicly exposing AsyncMapFailureSequence
's base
and transform
properties so that people don't have to reimplement the type in order to access those properties. Access to those properties can be useful for conforming it to user-defined protocols and I think it's unlikely that this type's contents are ever going to change.
Additionally, I think it's worth considering that non-escapable types are currently being added to the language, and it might make sense to make AsyncMapFailureSequence
a non-escapable type in order to avoid some restrictions of escaping closures. (I haven't been paying too much attention to those proposals, though, so I can't say for sure whether that would work or not.)