diff --git a/typed-racket-lib/typed-racket/core.rkt b/typed-racket-lib/typed-racket/core.rkt index 4e3758ad2..599459962 100644 --- a/typed-racket-lib/typed-racket/core.rkt +++ b/typed-racket-lib/typed-racket/core.rkt @@ -1,25 +1,26 @@ #lang racket/base -(require (rename-in "utils/utils.rkt") - (for-syntax racket/base) - (for-template racket/base) - "private/with-types.rkt" - "private/type-contract.rkt" - (except-in syntax/parse id) - racket/match racket/syntax +(require (for-syntax racket/base) + (for-template racket/base + "base-env/top-interaction.rkt") + racket/match + racket/syntax syntax/flatten-begin - "types/utils.rkt" - "types/abbrev.rkt" - "types/generalize.rkt" + (rename-in "utils/utils.rkt") + (except-in syntax/parse id) + "private/type-contract.rkt" + "private/with-types.rkt" + "rep/type-rep.rkt" + "standard-inits.rkt" + "tc-setup.rkt" "typecheck/provide-handling.rkt" "typecheck/tc-app-helper.rkt" - "rep/type-rep.rkt" - (for-template "base-env/top-interaction.rkt") - "utils/utils.rkt" - "utils/tc-utils.rkt" + "types/abbrev.rkt" + "types/generalize.rkt" + "types/utils.rkt" "utils/arm.rkt" - "standard-inits.rkt" - "tc-setup.rkt") + "utils/tc-utils.rkt" + "utils/utils.rkt") (provide mb-core ti-core wt-core wt-core-shallow wt-core-optional) @@ -48,10 +49,12 @@ (and (attribute opt?) (syntax-e (attribute opt?))))] [with-refinements? (and (or (attribute refinement-reasoning?) (with-refinements?)) - (when (not (eq? te-mode deep)) + (unless (eq? te-mode deep) (raise-arguments-error - (string->symbol (format "typed/racket/~a" (keyword->string (syntax-e te-attr)))) - "#:with-refinements unsupported")))]) + (string->symbol (format "typed/racket/~a" + (keyword->string + (syntax-e te-attr)))) + "#:with-refinements unsupported")))]) (tc-module/full te-mode stx pmb-form (λ (new-mod pre-before-code pre-after-code) (define ctc-cache (make-hash)) diff --git a/typed-racket-lib/typed-racket/logic/ineq.rkt b/typed-racket-lib/typed-racket/logic/ineq.rkt index eb5430c45..6f5b8b644 100644 --- a/typed-racket-lib/typed-racket/logic/ineq.rkt +++ b/typed-racket-lib/typed-racket/logic/ineq.rkt @@ -99,9 +99,8 @@ ;; Leq to the internal leq rep (define (Leq->leq l) - (match l - [(LeqProp: (LExp: c1 ts1) (LExp: c2 ts2)) - (leq (lexp c1 ts1) (lexp c2 ts2))])) + (match-define (LeqProp: (LExp: c1 ts1) (LExp: c2 ts2)) l) + (leq (lexp c1 ts1) (lexp c2 ts2))) ;; ***************************************************************************** @@ -215,10 +214,8 @@ [(eqv? a 0) (lexp 0 (make-terms))] [(= a 1) exp] [else - (match exp - [(lexp: c h) - (lexp (* c a) - (terms-scale h a))])])) + (match-define (lexp: c h) exp) + (lexp (* c a) (terms-scale h a))])) (module+ test (check-equal? (lexp-set (lexp* 17 '(42 x)) 'x 0) @@ -332,13 +329,15 @@ (-> lexp? (-> any/c any/c) string?) (define vars (terms-vars (lexp-vars e))) (define const (lexp-const e)) - (define term->string - (λ (x) (string-append (if (= 1 (lexp-coeff e x)) - "" - (number->string (lexp-coeff e x))) - "(" (if pp - (pp x) - (~a x)) ")"))) + (define (term->string x) + (string-append (if (= 1 (lexp-coeff e x)) + "" + (number->string (lexp-coeff e x))) + "(" + (if pp + (pp x) + (~a x)) + ")")) (cond [(terms-empty? vars) (number->string const)] [(zero? const) @@ -487,21 +486,18 @@ ;; leq2: ... + cx + .... <= ... + dx + ... (let-values ([(l1 r1) (leq-lexps leq1)] [(l2 r2) (leq-lexps leq2)]) - (let ([a (lexp-coeff l1 x)] [b (lexp-coeff r1 x)] - [c (lexp-coeff l2 x)] [d (lexp-coeff r2 x)]) - (cond - ;; leq1: ax <= lexp1 - ;; leq2: lexp2 <= dx - [(and (eqv? 0 b) (eqv? 0 c)) - (leq (lexp-scale l2 a) - (lexp-scale r1 d))] - ;; leq1: lexp1 <= bx - ;; leq2: cx <= lexp2 - [(and (eqv? 0 a) (eqv? 0 d)) - (leq (lexp-scale l1 c) - (lexp-scale r2 b))] - [else - (error 'leq-join "cannot join ~a and ~a by ~a" leq1 leq2 x)])))) + (define a (lexp-coeff l1 x)) + (define b (lexp-coeff r1 x)) + (define c (lexp-coeff l2 x)) + (define d (lexp-coeff r2 x)) + (cond + ;; leq1: ax <= lexp1 + ;; leq2: lexp2 <= dx + [(and (eqv? 0 b) (eqv? 0 c)) (leq (lexp-scale l2 a) (lexp-scale r1 d))] + ;; leq1: lexp1 <= bx + ;; leq2: cx <= lexp2 + [(and (eqv? 0 a) (eqv? 0 d)) (leq (lexp-scale l1 c) (lexp-scale r2 b))] + [else (error 'leq-join "cannot join ~a and ~a by ~a" leq1 leq2 x)]))) (module+ test (check-equal? (leq-join (leq (lexp* '(2 x)) @@ -600,36 +596,31 @@ (values xlhs xrhs (cons ineq nox))])))) (module+ test - (check-equal? (let-values ([(lt gt no) - (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) - (lexp* '(2 y)))) - 'x)]) - (list lt gt no)) + (check-equal? (call-with-values + (λ () (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y)))) 'x)) + list) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) -1))) (list) (list))) - (check-equal? (let-values ([(lt gt no) - (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) - (lexp* '(2 y))) - (leq (lexp* '(2 x) '(4 y)) - (lexp* '(2 y) '(42 x)))) - 'x)]) - (list lt gt no)) + (check-equal? (call-with-values (λ () + (sli-partition (list (leq (lexp* '(2 x) '(4 y) 1) (lexp* '(2 y))) + (leq (lexp* '(2 x) '(4 y)) + (lexp* '(2 y) '(42 x)))) + 'x)) + list) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) -1))) (list (leq (lexp* '(2 y)) (lexp* '(40 x)))) (list))) - (check-equal? (let-values ([(lt gt no) - (sli-partition (list (leq (lexp* '(2 x) '(4 y) -1) - (lexp* '(2 y))) - (leq (lexp* '(2 x) '(4 y)) - (lexp* '(2 y) '(42 x))) - (leq (lexp* '(2 z) '(4 y)) - (lexp* '(2 y) '(42 q)))) - 'x)]) - (list lt gt no)) + (check-equal? (call-with-values + (λ () + (sli-partition (list (leq (lexp* '(2 x) '(4 y) -1) (lexp* '(2 y))) + (leq (lexp* '(2 x) '(4 y)) (lexp* '(2 y) '(42 x))) + (leq (lexp* '(2 z) '(4 y)) (lexp* '(2 y) '(42 q)))) + 'x)) + list) (list (list (leq (lexp* '(2 x)) (lexp* '(-2 y) 1))) (list (leq (lexp* '(2 y)) diff --git a/typed-racket-lib/typed-racket/rep/base-type-rep.rkt b/typed-racket-lib/typed-racket/rep/base-type-rep.rkt index f5762b27d..c2c441602 100644 --- a/typed-racket-lib/typed-racket/rep/base-type-rep.rkt +++ b/typed-racket-lib/typed-racket/rep/base-type-rep.rkt @@ -1,12 +1,12 @@ #lang racket/base -(require "rep-utils.rkt" - "core-rep.rkt" - "type-mask.rkt" - racket/match - (for-syntax racket/base +(require (for-syntax racket/base racket/syntax - syntax/parse)) + syntax/parse) + racket/match + "core-rep.rkt" + "rep-utils.rkt" + "type-mask.rkt") (provide define-base-types Base-bits: diff --git a/typed-racket-lib/typed-racket/rep/base-union.rkt b/typed-racket-lib/typed-racket/rep/base-union.rkt index c68b8cdb2..bdcffa2c7 100644 --- a/typed-racket-lib/typed-racket/rep/base-union.rkt +++ b/typed-racket-lib/typed-racket/rep/base-union.rkt @@ -59,10 +59,8 @@ (app BaseUnion-bases bases)))]))) (define (BaseUnion-bases t) - (match t - [(BaseUnion: bbits nbits) - (cond - [(eqv? bbits 0) (nbits->base-types nbits)] - [(eqv? nbits 0) (bbits->base-types bbits)] - [else (append (bbits->base-types bbits) - (nbits->base-types nbits))])])) + (match-define (BaseUnion: bbits nbits) t) + (cond + [(eqv? bbits 0) (nbits->base-types nbits)] + [(eqv? nbits 0) (bbits->base-types bbits)] + [else (append (bbits->base-types bbits) (nbits->base-types nbits))])) diff --git a/typed-racket-lib/typed-racket/rep/core-rep.rkt b/typed-racket-lib/typed-racket/rep/core-rep.rkt index 3e32e576f..c3178cf4d 100644 --- a/typed-racket-lib/typed-racket/rep/core-rep.rkt +++ b/typed-racket-lib/typed-racket/rep/core-rep.rkt @@ -247,7 +247,7 @@ (-> Result? Result?) (match-define (Result: type propset optobject n-existentials) result) (cond - [(> n-existentials 0) + [(positive? n-existentials) (define syms (hash-ref type-var-name-table result (build-list n-existentials (lambda _ (gensym))))) (define vars (map make-F syms)) (make-Result (instantiate-type type vars) (instantiate-propset propset vars) optobject n-existentials)] diff --git a/typed-racket-lib/typed-racket/rep/free-ids.rkt b/typed-racket-lib/typed-racket/rep/free-ids.rkt index f069dd39a..6c8235874 100644 --- a/typed-racket-lib/typed-racket/rep/free-ids.rkt +++ b/typed-racket-lib/typed-racket/rep/free-ids.rkt @@ -69,11 +69,9 @@ (cond [(member x seen free-identifier=?) (cons x seen)] [else - (begin0 - (let ([seen+x (cons x seen)]) - (for/or ([neighbor (in-list (cdr (assoc x deps free-identifier=?)))]) - (and (not (member neighbor visited free-identifier=?)) - (visit neighbor seen+x)))) + (define seen+x (cons x seen)) + (begin0 (for/or ([neighbor (in-list (cdr (assoc x deps free-identifier=?)))]) + (and (not (member neighbor visited free-identifier=?)) (visit neighbor seen+x))) (set! visited (cons x visited)))])) (match (for/or ([entry (in-list deps)]) (visit (car entry) '())) diff --git a/typed-racket-lib/typed-racket/rep/free-variance.rkt b/typed-racket-lib/typed-racket/rep/free-variance.rkt index 7a97a12c6..b6c93242a 100644 --- a/typed-racket-lib/typed-racket/rep/free-variance.rkt +++ b/typed-racket-lib/typed-racket/rep/free-variance.rkt @@ -1,12 +1,12 @@ #lang racket/base -(require racket/match - racket/set +(require racket/lazy-require racket/list - "../rep/type-constr.rkt" - "../utils/utils.rkt" - racket/lazy-require + racket/match + racket/set + "../env/type-constr-env.rkt" "../private/user-defined-type-constr.rkt" - "../env/type-constr-env.rkt") + "../rep/type-constr.rkt" + "../utils/utils.rkt") (provide ;; Variances @@ -123,18 +123,14 @@ (for/fold ([hash (hasheq)] [computed null]) ([frees (in-list freess)]) - (match frees - [(combined-frees new-hash new-computed) - (values (combine-hashes (list hash new-hash)) - (append new-computed computed))]))) + (match-define (combined-frees new-hash new-computed) frees) + (values (combine-hashes (list hash new-hash)) (append new-computed computed)))) (combined-frees hash computed)) (define (free-vars-remove frees name) - (match frees - [(combined-frees hash computed) - (combined-frees (hash-remove hash name) - (map (λ (v) (remove-frees v name)) computed))])) + (match-define (combined-frees hash computed) frees) + (combined-frees (hash-remove hash name) (map (λ (v) (remove-frees v name)) computed))) ;; (define (free-vars-names vars) diff --git a/typed-racket-lib/typed-racket/rep/object-rep.rkt b/typed-racket-lib/typed-racket/rep/object-rep.rkt index 418563b55..d9b1e3212 100644 --- a/typed-racket-lib/typed-racket/rep/object-rep.rkt +++ b/typed-racket-lib/typed-racket/rep/object-rep.rkt @@ -268,10 +268,10 @@ [(list (? exact-integer? coeff) (? Path? p)) (values c (terms-set ts p (+ coeff (terms-ref ts p))))] [(list (? exact-integer? coeff) (? name-ref/c nm)) - (let ([p (-id-path nm)]) - (if (Empty? nm) - (values c ts) - (values c (terms-set ts p (+ coeff (terms-ref ts p))))))] + (define p (-id-path nm)) + (if (Empty? nm) + (values c ts) + (values c (terms-set ts p (+ coeff (terms-ref ts p)))))] [(? exact-integer? new-const) (values (+ new-const c) ts)] [(LExp: c* ts*) @@ -313,9 +313,7 @@ (-> OptObject? (or/c #f exact-integer?)) (match l [(LExp: c terms) - (if (hash-empty? terms) - c - #f)] + (and (hash-empty? terms) c)] [_ #f])) (define/cond-contract (in-LExp? obj l) @@ -388,6 +386,5 @@ (make-LExp* (+ c1 c2) (terms-add terms1 terms2))])) (define (add-path-to-lexp p l) - (match l - [(LExp: const terms) - (make-LExp* const (terms-set terms p (add1 (terms-ref terms p))))])) + (match-define (LExp: const terms) l) + (make-LExp* const (terms-set terms p (add1 (terms-ref terms p))))) diff --git a/typed-racket-lib/typed-racket/rep/prop-rep.rkt b/typed-racket-lib/typed-racket/rep/prop-rep.rkt index 953332504..069950753 100644 --- a/typed-racket-lib/typed-racket/rep/prop-rep.rkt +++ b/typed-racket-lib/typed-racket/rep/prop-rep.rkt @@ -143,8 +143,7 @@ [#:for-each (f) (for-each f ps)] [#:custom-constructor/contract (-> (listof (or/c TypeProp? NotTypeProp? LeqProp?)) OrProp?) - (let ([ps (sort ps (λ (p q) (unsafe-fx<= (eq-hash-code p) - (eq-hash-code q))))]) + (let ([ps (sort ps unsafe-fx<= #:key eq-hash-code)]) (intern-single-ref! orprop-intern-table ps diff --git a/typed-racket-lib/typed-racket/rep/rep-switch.rkt b/typed-racket-lib/typed-racket/rep/rep-switch.rkt index 97be1d125..2bb01a381 100644 --- a/typed-racket-lib/typed-racket/rep/rep-switch.rkt +++ b/typed-racket-lib/typed-racket/rep/rep-switch.rkt @@ -1,12 +1,12 @@ #lang racket/base -(require "rep-utils.rkt" +(require (for-syntax racket/base + racket/list + racket/syntax + syntax/parse) racket/match racket/unsafe/ops - (for-syntax racket/base - syntax/parse - racket/list - racket/syntax)) + "rep-utils.rkt") (provide define-rep-switch) @@ -35,7 +35,7 @@ (~var clause (switch-clause #'(pre-args ...) #'arg #'(post-args ...))) ... [(~datum else:) . default]) (define name-symbols (map syntax->datum (syntax->list #'(clause.name ...)))) - (unless (not (null? name-symbols)) + (when (null? name-symbols) (raise-syntax-error 'define-switch "switch cannot be null" stx)) (define sorted-name-symbols (sort name-symbols symbol (length (syntax->list #'flds)) 0))) + (positive? (length (syntax->list #'flds))))) (raise-syntax-error 'def-rep "singletons cannot have fields or the #:no-provide option" #'var)) (when (and (attribute base?) diff --git a/typed-racket-lib/typed-racket/rep/type-constr.rkt b/typed-racket-lib/typed-racket/rep/type-constr.rkt index 8ba2c2144..172c10a47 100644 --- a/typed-racket-lib/typed-racket/rep/type-constr.rkt +++ b/typed-racket-lib/typed-racket/rep/type-constr.rkt @@ -1,9 +1,9 @@ #lang racket/base -(require racket/match +(require racket/generic racket/lazy-require racket/list - racket/string - racket/generic) + racket/match + racket/string) (provide print-kind make-type-constr diff --git a/typed-racket-lib/typed-racket/rep/type-rep.rkt b/typed-racket-lib/typed-racket/rep/type-rep.rkt index b412e09e8..9acc174b8 100644 --- a/typed-racket-lib/typed-racket/rep/type-rep.rkt +++ b/typed-racket-lib/typed-racket/rep/type-rep.rkt @@ -3,38 +3,39 @@ ;; This module provides type representations and utility functions ;; and pattern matchers on types -(require "../utils/utils.rkt" - (for-syntax "../utils/utils.rkt")) +(require (for-syntax "../utils/utils.rkt") + "../utils/utils.rkt") ;; TODO use contract-req -(require "../utils/tc-utils.rkt" - "../utils/prefab.rkt" - "../utils/identifier.rkt" +(require (for-syntax racket/base + racket/syntax + syntax/parse) + racket/contract + racket/format + racket/lazy-require + racket/list + racket/match + racket/string + racket/unsafe/undefined + syntax/id-set + syntax/id-table + (only-in racket/generic define/generic) "../env/env-utils.rkt" - "rep-utils.rkt" - "type-constr.rkt" + "../utils/identifier.rkt" + "../utils/prefab.rkt" + "../utils/tc-utils.rkt" + "base-type-rep.rkt" + "base-types.rkt" + "base-union.rkt" "core-rep.rkt" + "free-variance.rkt" + "numeric-base-types.rkt" "object-rep.rkt" "prop-rep.rkt" - "values-rep.rkt" + "rep-utils.rkt" + "type-constr.rkt" "type-mask.rkt" - "free-variance.rkt" - "base-type-rep.rkt" - "base-types.rkt" - "numeric-base-types.rkt" - "base-union.rkt" - racket/match racket/list - racket/format - syntax/id-table - syntax/id-set - racket/contract - racket/string - (only-in racket/generic define/generic) - racket/lazy-require - racket/unsafe/undefined - (for-syntax racket/base - racket/syntax - syntax/parse)) + "values-rep.rkt") (provide (except-out (all-from-out "core-rep.rkt" "base-type-rep.rkt" @@ -1154,8 +1155,8 @@ (match ts [(list) (-refine Univ prop)] [(list t) (-refine t prop)] - [_ (let ([t (make-Intersection ts -tt elems)]) - (-refine t prop))])] + [_ (define t (make-Intersection ts -tt elems)) + (-refine t prop)])] [(cons arg args) (match arg [(Univ:) (loop ts elems prop args)] @@ -1806,7 +1807,7 @@ ;; sorts the given field of a Row by the member name (define (sort-row-clauses clauses) - (sort clauses (λ (x y) (symbolvalues res)) (define arg-tys (match return-ty [(Values: (list (Result: t* _ _) ...)) t*])) (add-typeof-expr #'op-name (ret (->* arg-tys return-ty :T+ #t))) diff --git a/typed-racket-lib/typed-racket/typed-reader.rkt b/typed-racket-lib/typed-racket/typed-reader.rkt index 7cb6e9340..a9f157bcc 100644 --- a/typed-racket-lib/typed-racket/typed-reader.rkt +++ b/typed-racket-lib/typed-racket/typed-reader.rkt @@ -8,73 +8,82 @@ (define (skip-whitespace port) ;; Skips whitespace characters, sensitive to the current ;; readtable's definition of whitespace - (let ([ch (peek-char port)]) - (unless (eof-object? ch) - ;; Consult current readtable: - (let-values ([(like-ch/sym proc dispatch-proc) - (readtable-mapping (current-readtable) ch)]) - ;; If like-ch/sym is whitespace, then ch is whitespace - (when (and (char? like-ch/sym) - (char-whitespace? like-ch/sym)) - (read-char port) - (skip-whitespace port)))))) + (define ch (peek-char port)) + (unless (eof-object? ch) + ;; Consult current readtable: + (define-values (like-ch/sym proc dispatch-proc) (readtable-mapping (current-readtable) ch)) + ;; If like-ch/sym is whitespace, then ch is whitespace + (when (and (char? like-ch/sym) (char-whitespace? like-ch/sym)) + (read-char port) + (skip-whitespace port)))) (define (skip-comments read-one port src) ;; Recursive read, but skip comments and detect EOF (let loop () - (let ([v (read-one)]) - (cond - [(special-comment? v) (loop)] - [(eof-object? v) - (let-values ([(l c p) (port-next-location port)]) - (raise-read-eof-error "unexpected EOF in type annotation" src l c p 1))] - [else v])))) + (define v (read-one)) + (cond + [(special-comment? v) (loop)] + [(eof-object? v) + (define-values (l c p) (port-next-location port)) + (raise-read-eof-error "unexpected EOF in type annotation" src l c p 1)] + [else v]))) (define (parse port read-one src) (skip-whitespace port) - (let ([name (read-one)]) - (begin0 - (begin (skip-whitespace port) - (let ([next (read-one)]) - (case (syntax-e next) - ;; type annotation - [(:) (skip-whitespace port) - (type-label-property name (syntax->datum (read-one)))] - [(::) (skip-whitespace port) - (datum->syntax name `(ann ,name : ,(read-one)))] - [(@) (let ([elems (let loop ([es '()]) - (skip-whitespace port) - (if (equal? #\} (peek-char port)) - (reverse es) - (loop (cons (read-one) es))))]) - (datum->syntax name `(inst ,name : ,@elems)))] - ;; arbitrary property annotation - [(PROP) (skip-whitespace port) - (let* ([prop-name (syntax-e (read-one))]) - (skip-whitespace port) - (syntax-property name prop-name (read-one)))] - ;; otherwise error - [else - (let-values ([(l c p) (port-next-location port)]) - (raise-read-error (format "typed expression ~a must be followed by :, ::, or @" - (syntax->datum name)) src l c p 1))]))) - (skip-whitespace port) - (let ([c (read-char port)]) - (unless (equal? #\} c) - (let-values ([(l c p) (port-next-location port)]) - (raise-read-error (format "typed expression ~a not properly terminated" (syntax->datum name)) src l c p 1))))))) + (define name (read-one)) + (begin0 (begin + (skip-whitespace port) + (let ([next (read-one)]) + (case (syntax-e next) + ;; type annotation + [(:) + (skip-whitespace port) + (type-label-property name (syntax->datum (read-one)))] + [(::) + (skip-whitespace port) + (datum->syntax name `(ann ,name : ,(read-one)))] + [(@) + (let ([elems (let loop ([es '()]) + (skip-whitespace port) + (if (equal? #\} (peek-char port)) + (reverse es) + (loop (cons (read-one) es))))]) + (datum->syntax name `(inst ,name : ,@elems)))] + ;; arbitrary property annotation + [(PROP) + (skip-whitespace port) + (let* ([prop-name (syntax-e (read-one))]) + (skip-whitespace port) + (syntax-property name prop-name (read-one)))] + ;; otherwise error + [else + (let-values ([(l c p) (port-next-location port)]) + (raise-read-error (format "typed expression ~a must be followed by :, ::, or @" + (syntax->datum name)) + src + l + c + p + 1))]))) + (skip-whitespace port) + (let ([c (read-char port)]) + (unless (equal? #\} c) + (let-values ([(l c p) (port-next-location port)]) + (raise-read-error (format "typed expression ~a not properly terminated" + (syntax->datum name)) + src + l + c + p + 1)))))) (define parse-id-type - (case-lambda - [(ch port src line col pos) - ;; `read-syntax' mode - (datum->syntax - #f - (parse port - (lambda () (read-syntax src port )) - src) - (let-values ([(l c p) (port-next-location port)]) - (list src line col pos (and pos (- p pos)))))])) + (λ (ch port src line col pos) + ;; `read-syntax' mode + (datum->syntax #f + (parse port (lambda () (read-syntax src port)) src) + (let-values ([(l c p) (port-next-location port)]) + (list src line col pos (and pos (- p pos))))))) (define (readtable) ; don't install the reader macro if a dispatch macro on the open brace has already been installed diff --git a/typed-racket-lib/typed/racket/unit.rkt b/typed-racket-lib/typed/racket/unit.rkt index ca42413f5..e241c1762 100644 --- a/typed-racket-lib/typed/racket/unit.rkt +++ b/typed-racket-lib/typed/racket/unit.rkt @@ -1,6 +1,9 @@ #lang racket/base -(require (except-in racket/unit +(require typed-racket/base-env/base-types-extra + typed-racket/base-env/signature-prims + typed-racket/base-env/unit-prims + (except-in racket/unit define-signature unit invoke-unit @@ -13,10 +16,7 @@ compound-unit/infer define-compound-unit/infer unit-from-context - define-unit-from-context) - typed-racket/base-env/unit-prims - typed-racket/base-env/base-types-extra - typed-racket/base-env/signature-prims) + define-unit-from-context)) (provide define-signature Unit