-
-
Notifications
You must be signed in to change notification settings - Fork 104
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
Unsoundness from stateful #:opaque predicates #457
Comments
What should happen? It depends on the definition of
Under definition 1, The current system assumes that @pnwamk Do you have any ideas? |
It's important that people be able to select X's out a union (or out of Note that we also use |
Ok, so that rules out 2, but it also rules out 3 and 4, because if |
If that's all we need to do, then it seems like less pain than I would expect from this problem (which I've known about for a long time). |
The |
Sorry for coming late to this. I haven't thought about this a lot, but changes such as dropping propositions from the predicate seem to me like they would break programs that currently type check today with no win for those users if they're using the feature safely... Ideally/in hind sight should |
|
Perhaps we should do the following:
|
There are two possible sound versions I can think of, and neither would work with
I was thinking of
|
@AlexKnauth, is the problem you're thinking of wrt |
Yes, that and types that contain opaque types, since the predicates for those could also be contradictory otherwise. |
I think edit: Ah, I just saw the suggestion that it could warn. That could be helpful... but I could also see it being a huge pain if I knowingly use unsafe-Opaque and then all sorts of Typed Racket features are constantly warning me about it. edit edit: Okay, the suggestion was only warning with Opaque - maybe that would be a nice middle ground. |
I think option (2) sounds promising (and less invasive). Here's my mental model for why the Our However, our current method for introducing an Opaque type So... yah, at least as far as I've thought about it, I'm sold on excluding the negative proposition from an axiomatized, Opaque predicate as the sensible approach for getting rid of potential unsoundness while allowing the user to still declare and work with Opaque types. |
For the sound version, would (require/typed [#:predicate-type Fish fish?]
[make-fish [String Number -> Fish]]
[lookup-fish [String -> Fish]])
;; fish? : Any -> Boolean : #:+ Fish
;; type Fish = (Predicate-Type fish?)
;; occurrence typing works in the then branch
(: f : Any -> Fish)
(define (f v)
(cond [(fish? v) v]
[(string? v) (lookup-fish v)]
[(number? v) (make-fish "blue" v)]
[else (make-fish "blue" 10)])) |
Yes, that seems like a good name. |
This is perhaps just personal preference, but I think "type predicate" sounds more natural than "predicate type", perhaps like how "number predicate" sounds more natural than "predicate number". I dunno, YMMV. Oh -- and does this form introduce BOTH the type and the predicate for the type? In that case I would even lean towards type/predicate (where the "with" punniness of the "/" I think is spot on with what we're doing). |
"type predicate" sounds like it is a predicate, not what this is. "predicate type" expresses that it is a type, but it's still slightly ambiguous. I'm not sure whether it will be interpreted to mean the type defined by a predicate or the type of a predicate. |
|
|
Those names sound like they're describing the predicate. The primary purpose of this is to introduce the type. What kind of type is it? A predicate type. |
So it is introducing a type along with a predicate? How about |
or more simply |
Sorry, I've said my two bits -- Do what you feel is best =) |
Both |
Proposal for
|
What version of Racket are you using?
I'm using version 6.7.0.1
If you got an error message, please include it here.
I didn't get an error message. I added the number
16
to the byte string#"abcdefg"
and got abox
pointing to the number3136
as the answer.What should have happened?
I'm not sure. Maybe occurrence typing has to work differently for
#:opaque
predicates?What program did you run?
The text was updated successfully, but these errors were encountered: