Repository navigation
Get Lwt_result closer to Stdlib.Result - #927
Merged
Merged
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.
smorimoto
reviewed
Feb 3, 2022
| | Error e -> Error (f e) | ||
| | Ok x -> Ok x) | ||
| e | ||
| let map_err f e = map_error f e |
Member
There was a problem hiding this comment.
Why don't we mark this as deprecated as well?
Contributor
Author
There was a problem hiding this comment.
Isn't the deprecation warning in the interface sufficient?
Member
There was a problem hiding this comment.
Oops! I missed that they were at the end of the file!
smorimoto
reviewed
Feb 3, 2022
| (function | ||
| | Error e -> Lwt.bind (f e) fail | ||
| | Ok x -> return x) | ||
| let bind_lwt_err e f = bind_lwt_error e f |
smorimoto
approved these changes
Feb 3, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lwt_resulthas the double job of mapping fulfilled promises toOkand rejected (with an exception) toError, but also being useful to promises returning results. I had a little piece of code that was missing theiteranderrorfunctions, so I added them.Add
Lwt_result,Lwt_result.iter,Lwt_result.iter_error.Alias
Lwt_result.map_errandLwt_result.bind_lwt_errtoLwt_result.map_errorandLwt_result.bind_lwt_errorfor consistency with Stdlib. Maybe that part with the deprecation is too much.Took the liberty of adding
@since 5.6.0to the new functions but that may not be the proper version number.