diff --git a/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt b/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt index 5174bbda..ac32ab7e 100644 --- a/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt +++ b/collects/tests/typed-scheme/unit-tests/parse-type-tests.rkt @@ -1,5 +1,6 @@ #lang scheme/base (require "test-utils.ss" (for-syntax scheme/base) + racket/set (utils tc-utils) (env type-alias-env type-env-structs tvar-env type-name-env init-envs) (rep type-rep) @@ -105,8 +106,7 @@ [(Listof Number) (make-Listof N)] - [a (-v a) (extend-env (list 'a) (list (-v a)) - initial-tvar-env)] + [a (-v a) (set-add initial-tvar-env 'a)] [(All (a ...) (a ... -> Number)) (-polydots (a) ((list) [a a] . ->... . N))] diff --git a/collects/typed-scheme/env/index-env.rkt b/collects/typed-scheme/env/index-env.rkt index c2237755..4a6218ec 100644 --- a/collects/typed-scheme/env/index-env.rkt +++ b/collects/typed-scheme/env/index-env.rkt @@ -6,26 +6,26 @@ ;; to types representing the type variable ;; technically, the mapped-to type is unnecessary, but it's convenient to have it around? maybe? -(require racket/require "type-env-structs.rkt" (path-up "utils/tc-utils.rkt" "rep/type-rep.rkt")) +(require racket/require racket/set (path-up "utils/tc-utils.rkt")) (provide (all-defined-out)) ;; the initial type variable environment - empty ;; this is used in the parsing of types -(define initial-index-env (make-empty-env #hasheq())) +(define initial-index-env (seteq)) ;; a parameter for the current type variables (define current-indexes (make-parameter initial-index-env)) ;; takes a single index (define-syntax-rule (extend-indexes index . body) - (parameterize ([current-indexes (extend (current-indexes) index (make-F index))]) . body)) + (parameterize ([current-indexes (set-add (current-indexes) index)]) . body)) -(define (bound-index? v) (lookup (current-indexes) v (lambda (_) #f))) +(define (bound-index? v) (set-member? (current-indexes) v)) (define (infer-index stx) - (define bounds (env-keys+vals (current-indexes))) + (define bounds (set-map (current-indexes) values)) (when (null? bounds) (tc-error/stx stx "No type variable bound with ... in scope for ... type")) (unless (null? (cdr bounds)) (tc-error/stx stx "Cannot infer bound for ... type")) - (car (car bounds))) \ No newline at end of file + (car bounds)) \ No newline at end of file diff --git a/collects/typed-scheme/env/tvar-env.rkt b/collects/typed-scheme/env/tvar-env.rkt index dbe26849..88e933e0 100644 --- a/collects/typed-scheme/env/tvar-env.rkt +++ b/collects/typed-scheme/env/tvar-env.rkt @@ -7,18 +7,18 @@ ;; to types representing the type variable ;; technically, the mapped-to type is unnecessary, but it's convenient to have it around? maybe? -(require racket/require "type-env-structs.rkt" (path-up "rep/type-rep.rkt")) +(require racket/set) (provide (all-defined-out)) ;; the initial type variable environment - empty ;; this is used in the parsing of types -(define initial-tvar-env (make-empty-env #hasheq())) +(define initial-tvar-env (seteq)) ;; a parameter for the current type variables (define current-tvars (make-parameter initial-tvar-env)) ;; takes a list of vars (define-syntax-rule (extend-tvars vars . body) - (parameterize ([current-tvars (extend-env vars (map make-F vars) (current-tvars))]) . body)) + (parameterize ([current-tvars (foldr (λ (v s) (set-add s v)) (current-tvars) vars)]) . body)) -(define (bound-tvar? v) (lookup (current-tvars) v (lambda (_) #f))) \ No newline at end of file +(define (bound-tvar? v) (set-member? (current-tvars) v)) \ No newline at end of file