RFC for initial implementation of types for untyped contracts#833
RFC for initial implementation of types for untyped contracts#833btlachance wants to merge 2 commits intoracket:masterfrom
Conversation
4c5e0c2 to 3b5e871 Compare | A few initial thoughts:
|
| (Should these go in the RFC?) 1. Can you given an example with a function contract and say what the result type is? Sure, the contract Another: The type I'm using for 2. Can you say more about the status of dependent contracts? The only dependent contract I have is
Big things missing:
And type-system wise: dependent function contracts just have a contract type with ordinary function types in the input and output positions. 3. Can you say how the Single-argument function types are a subtype of In the current implementation the function application code ( |
| Adding the first two answers to the RFC would be good. For the |
bennn left a comment
There was a problem hiding this comment.
Can the RFC explain why there aren't types for chaperone & impersonator contracts?
I like the 2-arg contract type. But why not use TR's prop syntax and have (Contract Any #:+ Integer)? Because it's a chore to write #:+ everywhere?
Allowing FlatContract as an operator sounds good. Maybe the error message can suggest adding contract-first-order-passes? for the edge cases.
| This value flow is reflected in the type of a function contract. For | ||
| our `(->/c positive? positive?)` the type is | ||
| | ||
| (Contract (-> {2} Positive-Real Real {3}) |
There was a problem hiding this comment.
This notation is a little confusing. How about (Contract (-> #|2|#Positive-Real #|3|#Real) ....) so that:
- it's valid TR syntax
- the labels always come first
- the labels touch the names they belong to
There was a problem hiding this comment.
Good idea. Will update the RFC
| because that's the output type of the range contract. This means that | ||
| if we apply this contract to a function, then the resuling function | ||
| returns at least a `Positive-Real` if it returns at all. | ||
| |
There was a problem hiding this comment.
Add quick examples for lists, structs, and/or vectors?
I'm guessing: functions are a great example because a function type has input & output. Other contract-types should be simpler, but it'd be nice to have that confirmed.
There was a problem hiding this comment.
I'll add a list example.
As far as structs go: No support yet for struct/c, and I might need to provide a variant of contract-out that does some additional checks; At the moment the PR just reprovides Racket's contract-out. I updated the RFC with notes about that.
For vectors, are you interested in mutable vectors specifically? or just any vector contract?
This is a great idea! I've only thought about this a little but I think using a union type for But it's not clear how to admit
Is your thought that the "specific type" for the result should be a subtype of the |
| (I'll add these to the RFC too. But replying here first.)
AFAIK there's no reason to not have them, it just wasn't part of the initial work. It was something we talked about eventually wanting though. After adding them, I think the
No complaints here about the proposition syntax, but I haven't used it often enough in TR to have formed much of an opinion; We just never thought of it. But I like this idea a lot since the output type seems analagous to a proposition. Since there is a default proposition for a function type, using the proposition syntax for contract types suggests I might need to figure out a sensible default there, too.
I'm not sure how |
I wouldn't worry about the default for now, and just require
Either one: |
I'd appreciate any feedback you all have on the RFC.
As an FYI: When I read "guide-level explanation" in the RFC template, for some reason I thought the audience of the RFC might not just be other TR developers. So what I wrote might be more than what was actually wanted...
(The section "Reference-level explanation" is probably not detailed enough, but I'm having trouble figuring out what more needs to be said or what should be excerpted from another source.)