-
Notifications
You must be signed in to change notification settings - Fork 145
Create FS-1135-map-binary-search.md #734
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
base: main
Are you sure you want to change the base?
Conversation
|
@KevinRansom @vzarytovskii @abelbraaksma Comments on this please? |
|
@reinux : I am still thinking of a better self-explainable API, I don't think a tuple of 3 with same types is best. Even though the ordering (previous,match,next) is likely the most natural one here. Just to show another proposal, I have tried to DU-model the outcomes, but I do not think it is any better to your proposal here. The number of possible combinations is an inherent part of binary search if we want this to be a primitive supporting all sorts of scenarios. |
|
I like the functionality and the API. |
The more I think about it, the more I'm liking
As for the return type, I think the only option we haven't explored yet is a single-case union with named parameters: type MapSearchResult<'k, 'v> =
MapSearchResult of left: ('k, 'v) option * exact: ('k, 'v) option * right: ('k, 'v) optionThis would effectively be the same as the tuple version, except that we'd be trading conciseness with some IDE assistance. I'm likewise unsure whether this is the best approach either. |
|
From the options so far, this API seems the best for avoiding errors and for communicating intent clearly. type MapSearchResult<'k, 'v> =
MapSearchResult of left: ('k, 'v) option * exact: ('k, 'v) option * right: ('k, 'v) option
|
|
The |
|
There are more benefits to a custom type over tuples for API contracts:
|
|
@T-Gro A binary breaking change would still occur when adding another field to The point about older compilers and IDE tools may apply but documentation would help - we can't be stuck in the past with API additions. Also, are extensions really a point of concern? What are the use cases for extending MapSearchResult at all, as opposed to using a function for it? |
|
T-Gro
left a comment
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.
See #734 (comment) for the last changes to incorporate.
After that is done, this PR can be merged.
Rendered RFC