WIP: Add Type/Predicate and make-positive-predicate #867
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.