-
Notifications
You must be signed in to change notification settings - Fork 25
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
Use a more idiomatic edgedb-native Range #341
Comments
I tend to be against breaking changes whose justification is "it makes more sense some other way". Fortunately for this issue, there is a good reason for the proposed change: Current range definition allows the following to exist: Range {
lower: None,
upper: None,
inc_lower: true,
inc_upper: true,
empty: false,
} ... which is very strange, as not having a bound and it being an inclusive does not go together. It is also possible to set empty to true and set other properties, which is also confusing. I like your option 3 the most. Feels most understandable to me, it does not use type aliases and it also support the "modelling when user knows the range not to be empty".
struct MultiRange<T>(Vec<BoundedRange<T>>) |
Option 1 to 3 have two problems that option 4 can fix:
The basic changes above aren't breaking changes by themselves. But removing the weird accessors is. And adding a I think for now I'll go for a mix of 3 and 4:
This allows fixing the non-canonical empty problem, and defers handling of |
Another problematic feature is: |
If we use edit: Looks like causes problems for |
Unfortunately there were some unexpected challenges: NaN handling Edgedb treats I also implemented that trait for Canonicalizing Bounds EdgeDB cononicalizes discrete ranges so the start is inclusive and the end exclusive. The constructors of the rust range types do the same. This is done via the See PR #345 (doesn't compile yet) |
The native EdgeDB type looks like this:
I think a more idomatic way of representing that would be one of the following. All of these can still represent every valid edgedb value.
I don't think these are breaking changes, since the current struct has private fields. However the fields have corresponding public accessors, which I'd like to get rid of if breaking changes are allowed (or at least deprecate).
or
or
or
I like the last one best, since it
NonEmptyRange
could be useful to be used in the model if the user knows it's never empty. It could also come in handy to model multi-ranges as something likeVec<NonEmptyRange<T>>
(I'm assuming multi-ranges can't contain individual empty ranges).The text was updated successfully, but these errors were encountered: