Repository navigation
WIP: Add Type/Predicate and make-positive-predicate - #867
Closed
AlexKnauth wants to merge 3 commits into
Closed
AlexKnauth wants to merge 3 commits into
AlexKnauth wants to merge 3 commits into
Conversation
TODO: make-predicate should error on Type/Predicate types, but make-positive-predicate should succeed
Member
|
What happens if we just change I'd really prefer not to add a lot more mechanism here. |
Member
Author
|
If we did that then |
Member
|
That's also true of your proposal, I believe. |
Member
Author
|
Yes, with my proposal |
TODO: make-predicate should error on Type/Predicate types, but make-positive-predicate should succeed
The exact? field determines whether the contract must defice exactly whether the value has the type. exact? is true for make-predicate, but false for make-positive-predicate and everything else
Member
|
I should also say that this change will definitely require an RFC, and I encourage you to first write that and go through the process before working too much more on the implementation. |
Member
Author
|
Closed to be replaced by #882 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #457 by adding
Type/Predicateand#:type/predicateas sound versions of what's most useful aboutOpaqueand#:opaque.1. A type constructor
Type/Predicatethat takes a predicate id and produces a type. Iffoo?is a predicate, then(Type/Predicate foo?)produces a type for values that have passedfoo?even just once. So if(foo? x)returns#trueand then returns#false,xstill has typeFooafter that.2. A required/typed keyword
[#:type/predicate Foo foo?]that imports the predicatefoo?and defines the typeFooas(Type/Predicate foo?). Thefoo?predicate is imported with type(-> Any Boolean : #:+ Foo). It can not have type(-> Any Boolean : Foo).3. A new expression form
make-positive-predicatethat takes a type and produces a predicate with only the positive#:+proposition. So(make-positive-predicate X)will produce a predicate with the type(-> Any Boolean : #:+ X).(make-positive-predicate (Type/Predicate foo?))produces a predicate equivalent tofoo?with type(-> Any Boolean : #:+ (Type/Predicate foo?))(make-positive-predicate (Opaque foo?))also produces a predicate equivalent tofoo?with type(-> Any Boolean : #:+ (Opaque foo?))4. Make sure
make-predicateerrors onType/Predicatetypes, with an error message that suggests usingmake-positive-predicateinstead. It should give a warning onOpaquetypes, similarly suggestingmake-positive-predicateinstead.