From c95084cedf883807b2eecb37ba2ac14d7f4bc4ad Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sat, 11 Jan 2014 09:59:11 -0800 Subject: [PATCH] Change name of recursive contract to not colide with racket/contract. --- .../typed-racket/private/type-contract.rkt | 20 +++++----- .../typed-racket/static-contracts/README | 4 +- .../static-contracts/combinators/any.rkt | 2 +- .../combinators/case-lambda.rkt | 2 +- .../static-contracts/combinators/control.rkt | 2 +- .../static-contracts/combinators/function.rkt | 2 +- .../static-contracts/combinators/lengths.rkt | 2 +- .../static-contracts/combinators/none.rkt | 2 +- .../static-contracts/combinators/object.rkt | 2 +- .../combinators/parametric.rkt | 2 +- .../static-contracts/combinators/simple.rkt | 2 +- .../static-contracts/combinators/struct.rkt | 2 +- .../combinators/structural.rkt | 2 +- .../static-contracts/instantiate.rkt | 16 ++++---- .../static-contracts/optimize.rkt | 10 ++--- .../static-contracts/parametric-check.rkt | 7 ++-- .../static-contracts/structures.rkt | 38 +++++++++---------- 17 files changed, 58 insertions(+), 59 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt index d892c81a39..dd76246539 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -266,24 +266,24 @@ (match-define (and n*s (list untyped-n* typed-n* both-n*)) (generate-temporaries (list n n n))) (define rv (hash-set recursive-values n - (triple (recursive-contract-use untyped-n*) - (recursive-contract-use typed-n*) - (recursive-contract-use both-n*)))) + (triple (recursive-sc-use untyped-n*) + (recursive-sc-use typed-n*) + (recursive-sc-use both-n*)))) (case typed-side - [(both) (recursive-contract + [(both) (recursive-sc (list both-n*) (list (loop b 'both rv)) - (recursive-contract-use both-n*))] + (recursive-sc-use both-n*))] [(typed untyped) ;; TODO not fail in cases that don't get used (define untyped (loop b 'untyped rv)) (define typed (loop b 'typed rv)) (define both (loop b 'both rv)) - (recursive-contract + (recursive-sc n*s (list untyped typed both) - (recursive-contract-use (if (from-typed? typed-side) typed-n* untyped-n*)))])] + (recursive-sc-use (if (from-typed? typed-side) typed-n* untyped-n*)))])] [(Instance: (? Mu? t)) (t->sc (make-Instance (resolve-once t)))] [(Instance: (Class: _ _ (list (list names functions) ...))) @@ -305,9 +305,9 @@ (for/list ([fty flds] [mut? mut?]) (t->sc fty #:recursive-values (hash-set recursive-values - nm (recursive-contract-use nm*))))) - (recursive-contract (list nm*) (list (struct/sc nm (ormap values mut?) fields)) - (recursive-contract-use nm*))] + nm (recursive-sc-use nm*))))) + (recursive-sc (list nm*) (list (struct/sc nm (ormap values mut?) fields)) + (recursive-sc-use nm*))] [else (flat/sc #`(flat-named-contract '#,(syntax-e pred?) #,pred?))])] [(Syntax: (Base: 'Symbol _ _ _)) identifier?/sc] [(Syntax: t) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/README b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/README index b393b2ae1c..902e488176 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/README +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/README @@ -23,9 +23,9 @@ Internal Implementation Details: A static contract is one of three things: -recursive-contract: +recursive-sc: This introduces bindings for recursive contracts. -recursive-contract-use: +recursive-sc-use: This is a reference to a previously introduced recursive contract. combinator: This is a combinator or leaf contract. diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/any.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/any.rkt index e59d9a5733..ee8730220c 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/any.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/any.rkt @@ -6,7 +6,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/match - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base racket/syntax syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/case-lambda.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/case-lambda.rkt index b1e82ba1bd..92a2a3b816 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/case-lambda.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/case-lambda.rkt @@ -6,7 +6,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/list racket/match unstable/contract - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/control.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/control.rkt index 5366dfc2e3..670cbaf8ee 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/control.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/control.rkt @@ -6,7 +6,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/list racket/match unstable/contract - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/function.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/function.rkt index 64f570c9ee..8591a62530 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/function.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/function.rkt @@ -5,7 +5,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/list racket/match - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base racket/syntax syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/lengths.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/lengths.rkt index 2f1d000ac5..dd85409d39 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/lengths.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/lengths.rkt @@ -9,7 +9,7 @@ "../terminal.rkt" "simple.rkt" racket/match - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base)) (provide diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/none.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/none.rkt index 5cd27193f8..74e64fe156 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/none.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/none.rkt @@ -6,7 +6,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/match - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base racket/syntax syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/object.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/object.rkt index 97b2bfc801..85bdfbc043 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/object.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/object.rkt @@ -6,7 +6,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/list racket/match unstable/contract - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/class) (for-syntax racket/base syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/parametric.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/parametric.rkt index 07f0949751..c9e2e7d50f 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/parametric.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/parametric.rkt @@ -8,7 +8,7 @@ "../terminal.rkt" racket/list racket/match unstable/contract - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/parametric) (for-syntax racket/base syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt index 581d9a56f8..ff9256b4be 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/simple.rkt @@ -11,7 +11,7 @@ "../constraints.rkt" racket/list racket/match - (except-in racket/contract recursive-contract)) + racket/contract) (provide (contract-out diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/struct.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/struct.rkt index fbbb83d7ce..4d73706ed5 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/struct.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/struct.rkt @@ -5,7 +5,7 @@ (require "../structures.rkt" "../constraints.rkt" racket/list racket/match unstable/contract - (except-in racket/contract recursive-contract) + racket/contract (for-template racket/base racket/contract/base) (for-syntax racket/base syntax/parse)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt index 1b445973dc..5a8c84c38f 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/combinators/structural.rkt @@ -14,7 +14,7 @@ racket/contract/base racket/set unstable/contract) - (except-in racket/contract recursive-contract)) + racket/contract) (begin-for-syntax diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt index dcb9f4bf96..18aeaf27d9 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/instantiate.rkt @@ -7,19 +7,19 @@ racket/match racket/dict racket/sequence - (for-template racket/base (prefix-in c: racket/contract)) + racket/contract + (for-template racket/base racket/contract) "kinds.rkt" "parametric-check.rkt" "structures.rkt" "constraints.rkt" "equations.rkt") -(require (prefix-in c: racket/contract)) (provide - (c:contract-out + (contract-out [instantiate - (c:parametric->/c (a) ((static-contract? (c:-> #:reason (c:or/c #f string?) a)) - (contract-kind?) . c:->* . (c:or/c a syntax?)))])) + (parametric->/c (a) ((static-contract? (-> #:reason (or/c #f string?) a)) + (contract-kind?) . ->* . (or/c a syntax?)))])) ;; Providing these so that tests can work directly with them. (module* internals #f @@ -41,7 +41,7 @@ (define (compute-constraints sc max-kind) (define (recur sc) (match sc - [(recursive-contract names values body) + [(recursive-sc names values body) (close-loop names (map recur values) (recur body))] [(? sc?) (sc->constraints sc recur)])) @@ -74,7 +74,7 @@ (define (instantiate/inner sc recursive-kinds) (define (recur sc) (match sc - [(recursive-contract names values body) + [(recursive-sc names values body) (define raw-names (generate-temporaries names)) (define raw-bindings (for/list ([raw-name (in-list raw-names)] @@ -83,7 +83,7 @@ (define bindings (for/list ([name (in-list names)] [raw-name (in-list raw-names)]) - #`[#,name (c:recursive-contract #,raw-name + #`[#,name (recursive-contract #,raw-name #,(kind->keyword (hash-ref recursive-kinds name)))])) #`(letrec (#,@bindings #,@raw-bindings) #,(recur body))] diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt index 16b20040a6..1b3e9d5f5d 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/optimize.rkt @@ -11,7 +11,7 @@ racket/dict syntax/id-table racket/list - (except-in racket/contract recursive-contract) + racket/contract racket/match) @@ -106,9 +106,9 @@ (define table (make-free-id-table)) (define (recur sc variance) (match sc - [(recursive-contract-use id) + [(recursive-sc-use id) (dict-set! table id #t)] - [(recursive-contract names values body) + [(recursive-sc names values body) (recur body 'covariant) (for ([name (in-list names)] [value (in-list values)]) @@ -132,7 +132,7 @@ (define (trim sc variance) (match sc - [(recursive-contract names values body) + [(recursive-sc names values body) (define new-body (trim body 'covariant)) (define new-name-values @@ -145,7 +145,7 @@ (map second new-name-values))) (if (empty? new-names) new-body - (recursive-contract new-names new-values new-body))] + (recursive-sc new-names new-values new-body))] [else (sc-map sc trim)])) (trim sc 'covariant)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/parametric-check.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/parametric-check.rkt index ab058ff925..c3b1fa037a 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/parametric-check.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/parametric-check.rkt @@ -5,8 +5,7 @@ (require racket/match - - [except-in racket/contract recursive-contract] + racket/contract racket/dict syntax/id-table "structures.rkt" @@ -38,11 +37,11 @@ (variable-ref (get-var e)))))] [(parametric-var/sc: id) (add-equation! eqs (get-var sc) (lambda () 1))] - [(recursive-contract names values body) + [(recursive-sc names values body) (for ([name names] [value values]) (add-equation! eqs (get-rec-var name) (lambda () (variable-ref (get-var value))))) (add-equation! eqs (get-var sc) (lambda () (variable-ref (get-var body))))] - [(recursive-contract-use id) + [(recursive-sc-use id) (add-equation! eqs (get-var sc) (lambda () (variable-ref (get-rec-var id))))] [else (get-var sc)]) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt index 645348703d..74d3baf4fd 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/static-contracts/structures.rkt @@ -3,15 +3,15 @@ ;; Internal structures for representing a static contract. (require racket/match racket/list racket/generic - (except-in racket/contract recursive-contract) + racket/contract "kinds.rkt" "constraints.rkt") (provide (contract-out - (struct recursive-contract ([names (listof identifier?)] - [values (listof static-contract?)] - [body static-contract?])) - (struct recursive-contract-use ([name identifier?])) + (struct recursive-sc ([names (listof identifier?)] + [values (listof static-contract?)] + [body static-contract?])) + (struct recursive-sc-use ([name identifier?])) (struct combinator ([args sequence?])) (struct static-contract ()) [sc-map (static-contract? (static-contract? variance/c . -> . static-contract?) . -> . static-contract?)] @@ -28,8 +28,8 @@ (define variance/c (or/c 'covariant 'contravariant 'invariant)) -(define (recursive-contract-write-proc v port mode) - (match-define (recursive-contract names vals body) v) +(define (recursive-sc-write-proc v port mode) + (match-define (recursive-sc names vals body) v) (define recur (case mode [(#t) write] @@ -56,8 +56,8 @@ (recur body port) (display close port)) -(define (recursive-contract-use-write-proc v port mode) - (display (syntax->datum (recursive-contract-use-name v)) port)) +(define (recursive-sc-use-write-proc v port mode) + (display (syntax->datum (recursive-sc-use-name v)) port)) (define (combinator-write-proc v port mode) (match-define (combinator args) v) @@ -127,31 +127,31 @@ ;; - values : (listof static-contract?) ;; - body : static-contract? ;; names and value must have the same length. -(struct recursive-contract static-contract (names values body) +(struct recursive-sc static-contract (names values body) #:transparent #:methods gen:sc [(define (sc-map v f) (match v - [(recursive-contract names values body) - (recursive-contract names (map (λ (v) (f v 'covariant)) values) (f body 'covariant))])) + [(recursive-sc names values body) + (recursive-sc names (map (λ (v) (f v 'covariant)) values) (f body 'covariant))])) (define (sc-traverse v f) (match v - [(recursive-contract names values body) + [(recursive-sc names values body) (for-each (λ (v) (f v 'covariant)) values) (f body 'covariant) (void)]))] - #:methods gen:custom-write [(define write-proc recursive-contract-write-proc)]) + #:methods gen:custom-write [(define write-proc recursive-sc-write-proc)]) -;; A use of a contract bound by recursive-contract +;; A use of a contract bound by recursive-sc ;; - name : identifier? -(struct recursive-contract-use static-contract (name) +(struct recursive-sc-use static-contract (name) #:transparent #:methods gen:sc [(define (sc-map v f) v) (define (sc-traverse v f) (void)) - (define (sc->contract v f) (recursive-contract-use-name v)) - (define (sc->constraints v f) (variable-contract-restrict (recursive-contract-use-name v)))] - #:methods gen:custom-write [(define write-proc recursive-contract-use-write-proc)]) + (define (sc->contract v f) (recursive-sc-use-name v)) + (define (sc->constraints v f) (variable-contract-restrict (recursive-sc-use-name v)))] + #:methods gen:custom-write [(define write-proc recursive-sc-use-write-proc)]) ;; Super struct of static contract combinators. ;; Provides printing functionality.