Merged
Conversation
nojb
approved these changes
Jan 9, 2025
Contributor
There was a problem hiding this comment.
LGTM
I confess that I do not quite see what the name "retract" refers to, but I don't see any problems with it either.
One could also call it "codiagonal". Anyway, I don't have a strong opinion on naming.
A second approval from a core dev is needed before merging.
Contributor
Author
|
Thanks! |
Merged
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.
Split from #13696 please read the discussion there before commenting on the name.
Retracting the result type for equal success and error type
The
Result.retract : ('a, 'a) result -> 'afunction is useful when your success and error types eventually end up being the same and it's time to operate on either case uniformly. Formally this is justResult.fold ~ok:Fun.id ~error:Fun.idbut I would like to have it as a combinator.One example of this is when both case end up being an HTTP response and it's time to send it. For now I have it as other names in libraries like for example
Http.Response.resultand used here. But I'd prefer to have it simply asResult.retractas the pattern can be used in other contexts.