-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
Add Partial Order design proposal #276
base: master
Are you sure you want to change the base?
Conversation
normal lists still use a product order, only Lexicographic lists use lexicographic order
(This comment is long but mostly resolves itself, with a few exceptions. These are marked with backwards footnotes that look like "[bf_]." At the end is a list of references to the unresolved points.) Ooh, I take it this is meant primarily to be a generic partial order interface so that multiple parametrically polymorphic types with innate partial orderings can compose with each other like Some of my doubts at first were due to a few conflicting elements in the design. I'm going to think through several of them out loud to show how a lot of them resolve themselves:
I like the fact that in this design, checking for I get the impression this rather neatly accomplishes most of the important parts of what I was calling It looks like "Option A" here doesn't coincide with If the intention weren't for this to be used for partial ordering, this seems like a great design for Why it's okay that
|
Re: This would only be the case if Re: [bf2] I don't want to merge Re: short-cirtuiting for Ah, that's pretty clever! I like it. I'll have to change one thing in the definition of Re: [bf3] Yes The way I'm envisioning B and C working, the But if the type contains numbers and calls "recur" on them, Re: ordering for I'm worried that an interface intended to be an ordering with "always" will devolve into an ordering used as "now". I expect that many users will access mutable data in their ordering methods, especially when the only alternative that keeps "always" behavior would be to return NaN a lot which doesn't seem very useful. Re: [bf6] and I don't really understand what you mean for most of that. I guess there could be different But... I still don't understand how |
Implementations of other design-options will use some of the same datatypes and operations
Oh, I just meant (define (list-of-vectors/c element/c)
(listof (vector-immutableof element/c))) As a type alias, it could have a (define (list-of-vectors=? a b element=?)
; We compare the outer list.
(equal-always?/recur a b
(lambda (a b)
; We compare each vector in the list.
(equal-always?/recur a b
(lambda (a b)
; We compare the elements.
(element=? a b)))))) Oops, I could have actually used (define (list-of-vectors=? a b element=?)
; We compare the outer list.
(and (equal-always? (length a) (length b))
(for/and ([a (in-list a)] [b (in-list b)])
; We compare each vector in the list.
(and (equal-always? (vector-length a) (vector-length b))
(for/and ([a (in-vector a)] [b (in-vector b)])
; We compare the elements.
(element=? a b))))))
Okay, fair reason. :) It's also probably easier on Racket's optimizer (although I have hopes that static information could help the generic one expand to similar code).
Hmm, I'm not sure what your goal is with this. Why would
I didn't say That kind of thing could be done with Meanwhile, returning NaN from comparisons is useful because it helps programs fail faster, like you were saying (Did I just say NaN helps programs fail faster? 😄 Must be opposite day.) Since I'd like procedures and user-defined abstract data types to not be allowable as keys by default, I actually prefer a pretty steep departure from
I was talking about types whose Use cases for
|
Don't check eq? before that because cases like NaN can refuse to be equal to themselves.
depends on racket partial-order branch: https://github.com/AlexKnauth/racket/tree/partial-order TODO: test compare_hash_code
no need to have prop:partial-order built in to Racket if equal-hash-code/recur is built in instead
A
PartialOrder
interface intended to be privately implemented.Comparison operators like
=~
,<~
,>~
, and so on.Equality within tolerance for testing with
within
.Markdown-rendered design: https://github.com/AlexKnauth/rhombus-prototype/blob/partial-order/design/partial-order/partial-order.md