add predicates for concrete-only types#9
Conversation
|
I implemented a similar thing in my local and you should merge this in but I think it indicates a larger problem. In particular, non-lifted predicates like these dont affect what the solver has to do, so they are effectively dynamic concrete checks on a function argument, which a type system is supposed to get rid of! The problem I think is that our type system is too lax in letting concrete values become symbolic. So we need to generate checks like this to refine the type back to something concrete (because for our type system to be useful, it must preserve concreteness for as long as possible). But ideally, we should just preserve the concrete type in the first place. Here's a pattern I run into a lot: (define (f [x : Int]) -> Int x)
(f 4)The Does that make sense? Have you run into situations like this? Is that what you are using these asserts for? |
|
That makes sense, uses of Though some of the situations I've come across have been situations where it's a |
2bbad75 to
ddfbc82
Compare
|
Actually maybe case-lambda is not needed. Maybe some form of concreteness polymorphism? eg, where (define (f {X} [x : (X CInt)]) -> (X CInt)
(+ x 1)) |
|
We wrote this comment above If a predicate, say (define (string? v)
(for/all ([v v]) (concrete-string? v)))Then |
|
Types for container values like structs couldn't work like normal. If there was a struct declaration like (struct foo ([a : CInt]) #:transparent)Then values of this shape would have the type (foo CInt) : CFooAnd values of this shape would have the type (union (foo CInt) ...) : (U CFoo)However these values would be merged into (foo Int) : (U CFoo)Now that's fine as a (Note: I used the typed racket convention for structure types, where |
|
I do not think it's a good idea to use From what I've seen, it's a common idiom to rely on the the container remaining concrete, while the elements will be possibly symbolic (and Emina confirmed this last week). This means that we should not conflate Btw, the current typed definition of |
6d8f8e5 to
932af7c
Compare
|
Re: The current rule for What it currently does is unsound. For example when given It also doesn't preserve concrete types. For example in Ocelot there are places where (while typechecking a Update: fixed by #13 |
e229738 to
ae31402
Compare
ae31402 to
b670d73
Compare
24b381f to
ec64e2c
Compare
|
Superceded by #17. |
So that
assert-typecan work with concrete types likeCNat.I have a question. Is there any chance this could lead to unsoundness? For base types I don't think so, but I vaguely remember discussing this and deciding to only add predicates for possibly-symbolic types. Was that because it caused some problem that I'm not seeing now? Or was it just not necessary then?