- What is your evaluation of the proposal?
+1 and long overdue! I've used Result and/or Either in every substantial code base I've worked in.
A few thoughts:
-
I think
map/mapError/flatMap/flatMapErrorare indispensable and nicely mirror the existingmap/flatMapAPIs on arrays and optionals. -
I think
case success/var isSuccess/var valuelack naming uniformity/cohesion. (Same withcase failure/var isFailure/var error.) Why not name the properties after the case names? -
I think the
isSuccess/value/isFailure/errorproperties are all band-aids around the fact that enums aren't as ergonomic as they should be. I pitched a more general solution for this awhile back: Automatically derive properties for enum cases -
I find
foldextremely useful though I see it mostly as a band-aid around the fact that Swift doesn't have a lightweight expression-based switch statement. I'd probably still define afoldfunction, though, since it's handy for chaining and passing in functions as arguments, just likeforEach.
- Is the problem being addressed significant enough to warrant a change to Swift?
Yes.
- Does this proposal fit well with the feel and direction of Swift?
Yes (other than some of my comments earlier about naming and presence of fields like isSuccess and value).
- If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
Yes and this proposal compares nicely.
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
In-depth study and experience.