diff --git a/typed-racket-more/typed/syntax/modread.rkt b/typed-racket-more/typed/syntax/modread.rkt new file mode 100644 index 00000000..fa6615d8 --- /dev/null +++ b/typed-racket-more/typed/syntax/modread.rkt @@ -0,0 +1,22 @@ +#lang typed/racket/base + +(provide with-module-reading-parameterization check-module-form) + +(require typed/racket/unsafe) + +(unsafe-require/typed syntax/modread + [with-module-reading-parameterization + (All (A) (-> (-> A) A))] + [check-module-form + ;; check-module-form is already protected with the contract: + ;; (-> (or/c syntax? eof-object?) + ;; (or/c symbol? list?) + ;; (or/c string? path? false/c) + ;; any) ; This is any because the contract doesn't need + ;; ; to enforce that it's (or/c syntax? false/c). + ;; ; From the documentation: + (-> (U (Syntaxof Any) EOF) ; (or/c syntax? eof-object?) + Symbol ; symbol? + (U String False) ; (or/c string? false/c) + (U (Syntaxof Any) False))] ; (or/c syntax? false/c) + ) diff --git a/typed-racket-more/typed/syntax/readerr.rkt b/typed-racket-more/typed/syntax/readerr.rkt new file mode 100644 index 00000000..b95e167c --- /dev/null +++ b/typed-racket-more/typed/syntax/readerr.rkt @@ -0,0 +1,23 @@ +#lang typed/racket/base + +;; Since typed racket can generate contracts for these, this doesn't +;; need to use unsafe-require/typed. +(require/typed/provide syntax/readerr + [raise-read-error + (-> String + Any + (U Positive-Integer False) + (U Natural False) + (U Positive-Integer False) + (U Natural False) + [#:extra-srclocs (Listof srcloc)] + Nothing)] + [raise-read-eof-error + (-> String + Any + (U Positive-Integer False) + (U Natural False) + (U Positive-Integer False) + (U Natural False) + Nothing)] + ) diff --git a/typed-racket-more/typed/syntax/srcloc.rkt b/typed-racket-more/typed/syntax/srcloc.rkt new file mode 100644 index 00000000..c5f2f389 --- /dev/null +++ b/typed-racket-more/typed/syntax/srcloc.rkt @@ -0,0 +1,74 @@ +#lang typed/racket/base + +(provide Source-Location + Source-Location-List + Source-Location-Vector + source-location? + source-location-list? + source-location-vector? + check-source-location! + build-source-location + build-source-location-list + build-source-location-vector + build-source-location-syntax + source-location-known? + source-location-source + source-location-line + source-location-column + source-location-position + source-location-span + source-location-end + update-source-location + source-location->string + source-location->prefix + ) + +(require typed/racket/unsafe) + +(define-type Source-Location + (U srcloc + (Syntaxof Any) + Source-Location-List + Source-Location-Vector + False)) + +(define-type Source-Location-List + (List Any + (U Positive-Integer False) + (U Natural False) + (U Positive-Integer False) + (U Natural False))) + +(define-type Source-Location-Vector + (Vector Any + (U Positive-Integer False) + (U Natural False) + (U Positive-Integer False) + (U Natural False))) + +(unsafe-require/typed syntax/srcloc + [source-location? (-> Any Boolean)] + [source-location-list? (-> Any Boolean)] + [source-location-vector? (-> Any Boolean)] + [check-source-location! (-> Symbol Any Void)] + [build-source-location (-> Source-Location * srcloc)] + [build-source-location-list (-> Source-Location * Source-Location-List)] + [build-source-location-vector (-> Source-Location * Source-Location-Vector)] + [build-source-location-syntax (-> Source-Location * (Syntaxof Any))] + [source-location-known? (-> Source-Location Boolean)] + [source-location-source (-> Source-Location Any)] + [source-location-line (-> Source-Location (U Positive-Integer False))] + [source-location-column (-> Source-Location (U Natural False))] + [source-location-position (-> Source-Location (U Positive-Integer False))] + [source-location-span (-> Source-Location (U Natural False))] + [source-location-end (-> Source-Location (U Natural False))] + [update-source-location (-> Source-Location + [#:source Any] + [#:line (U Positive-Integer False)] + [#:column (U Natural False)] + [#:position (U Positive-Integer False)] + [#:span (U Natural False)] + Source-Location)] + [source-location->string (-> Source-Location String)] + [source-location->prefix (-> Source-Location String)] + )