-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get Lwt_result
closer to Stdlib.Result
#927
Conversation
For consistency with Stdlib.
Alias Lwt_result.map_err and Lwt_result.bind_lwt_err to Lwt_result.map_error and Lwt_result.bind_lwt_error for consistency with Stdlib.
For consistency with Stdlib.
Lwt.map | ||
(function | ||
| Error e -> Error (f e) | ||
| Ok x -> Ok x) | ||
e | ||
let map_err f e = map_error f e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we mark this as deprecated as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the deprecation warning in the interface sufficient?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! I missed that they were at the end of the file!
Lwt.bind e | ||
(function | ||
| Error e -> Lwt.bind (f e) fail | ||
| Ok x -> return x) | ||
let bind_lwt_err e f = bind_lwt_error e f |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
Lwt_result
has the double job of mapping fulfilled promises toOk
and rejected (with an exception) toError
, but also being useful to promises returning results. I had a little piece of code that was missing theiter
anderror
functions, so I added them.Add
Lwt_result
,Lwt_result.iter
,Lwt_result.iter_error
.Alias
Lwt_result.map_err
andLwt_result.bind_lwt_err
toLwt_result.map_error
andLwt_result.bind_lwt_error
for consistency with Stdlib. Maybe that part with the deprecation is too much.Took the liberty of adding
@since 5.6.0
to the new functions but that may not be the proper version number.