-
-
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
Make Opaque types correspond to positive predicates #882
base: master
Are you sure you want to change the base?
Conversation
d13d9a4
to
9def040
Compare
I'm not sure whether the warning message can be improved much further without adding more fields to the
|
After talking with @bennn, we've found a way to improve the warning message to recognize which form was used and suggest the positive version of that.
|
1b4f15c
to
c4a4543
Compare
I think we should start with the backwards-compatibility issue here.
2 can be checked using the |
The Main Distribution compiles without any new warnings. I haven’t run all the tests for those yet, but the runtime code shouldn’t be affected. I haven’t tested everything on the package server (I’m not sure on the best way to do that, I’ll listen to @capfredf), put of the packages I already use, |
You should start by looking at https://github.com/racket/pkg-build and following the readme steps. |
@AlexKnauth Before building packages with an on-going version of typed-racket, you need to build a racket bundled with that version of TR. Here is what I did 8 months ago: if the pkd-build runs on Ubuntu, then
if you run into any trouble, I'll be very happy to help you work them out. |
including the original source location, and suggesting the positive-predicate alternative
c4a4543
to
fa7aa5b
Compare
@bennn and I are part-way through running pkg-build on this, and we've gotten an error on the (require/typed web-server/servlet
[#:opaque Response response?]
...) On this (cond [(response? page-result) page-result]
[else (plain-page
"Assignments"
page-result)]) The else branch has less information known to the typechecker because |
What is the type of In general, open PRs that fix everything that would break is probably the minimum needed for the backwards-incompatibility here. |
The type of |
I ran a pkg-build. It seems to have failed (see below), but found a few packages that this PR breaks:
This is the error that the log ends on:Resolving "handy" via http://localhost:18333/built/catalog/ pkg: resolving via http://localhost:18333/built/catalog/pkg/handy?version=7.5.0.11 pkg: catalog response: #hash((author . "[email protected]") (checksum . "eebf73f88615dd7ee1f3ff83e174e04a74dfc792") (dependencies . (("html-parsing") ("base") ("db-lib") ("rackunit-lib") ("sxml") ("at-exp-lib"))) (description . "Utility functions that are missing from Racket -- e.g. 'say' (variadic displayln), 'multi-partition' (partition into more than two lists), better exception creation / trapping, database management, etc") (modules . ((lib "handy/sql.rkt") (lib "handy/test-more.rkt") (lib "handy/hash.rkt") (lib "handy/db.rkt") (lib "handy/deprecated/list-utils.rkt") (lib "handy/main.rkt") (lib "handy/list-utils.rkt") (lib "handy/net.rkt") (lib "handy/json.rkt") (lib "handy/try.rkt") (lib "handy/fsmonitor.rkt") (lib "handy/web.rkt") (lib "handy/struct.rkt") (lib "handy/utils.rkt") (lib "handy/thread.rkt") (lib "handy/HTML-TreeBuilder.rkt") (lib "handy/files/compression.rkt") (lib "handy/HTML-Element.rkt") (lib "handy/exceptions.rkt"))) (name . "handy") (ring . 2) (source . "http://localhost:18333/built/pkgs/handy.zip") (tags . ("database" "exceptions" "utility" "web"))) pkg: Assuming URL names a file pkg: Downloading http://localhost:18333/built/pkgs/handy.zip to /var/tmp/15763982081576398208468-handy.zip Downloading http://localhost:18333/built/pkgs/handy.zip pkg: caching for ("http://localhost:18333/built/pkgs/handy.zip" "eebf73f88615dd7ee1f3ff83e174e04a74dfc792") pkg: Downloading done, installing /var/tmp/15763982081576398208468-handy.zip as handy user break Timeout after 600 seconds ssh: failed context...: /home/ben/code/racket/pkg-build-test/pkg-build/main.rkt:1397:5 /home/ben/code/racket/pkg-build-test/pkg-build/main.rkt:123:0: build-pkgs57 "/home/ben/code/racket/pkg-build-test/run.rkt": [running body] temp37_0 for-loop run-module-instance!125 perform-require!78 Stopping VirtualBox machine "Racket pkg-build" 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% |
This PR provides an RFC and an implementation to do 3 things to address #457 :
Change
require/typed
[#:opaque t pred]
to givepred
the type(-> Any Boolean : #:+ t)
instead of type(-> Any Boolean : t)
. So if(pred x)
returns true and then returns false,x
still has typet
after that.Add
make-positive-predicate
anddefine-positive-predicate
, to take a type and produce a predicate with only the positive#:+
proposition. So(make-positive-predicate t)
will produce a predicate with the type(-> Any Boolean : #:+ t)
.Change
make-predicate
to give a warning on Opaque types.Things to clean up before it's ready:
make-predicate
on Opaque types should be improved, to recognize what form it came from and suggest alternative forms. When the warning is triggered bymake-predicate
, it should suggest usingmake-positive-predicate
instead.