Added annotations to plain for and for* in typed code.

This commit is contained in:
Vincent St-Amour 2010-08-27 17:16:14 -04:00
parent b386f01ee4
commit d3ee52d451
4 changed files with 21 additions and 7 deletions

View File

@ -2,7 +2,7 @@
(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app)
(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app for for*)
(except "private/prims.rkt")
(except "private/base-types.rkt")
(except "private/base-types-extra.rkt"))
@ -18,4 +18,4 @@
(for-syntax "private/base-types-extra.rkt"))
(provide (rename-out [with-handlers: with-handlers])
(for-syntax (all-from-out "private/base-types-extra.rkt"))
assert with-type)
assert with-type for for*)

View File

@ -23,7 +23,9 @@ This file defines two sorts of primitives. All of them are provided into any mod
:
(rename-out [define-typed-struct define-struct:]
[lambda: λ:]
[define-typed-struct/exec define-struct/exec:]))
[define-typed-struct/exec define-struct/exec:]
[for/annotation for]
[for*/annotation for*]))
(require "../utils/utils.rkt"
racket/base
@ -427,6 +429,18 @@ This file defines two sorts of primitives. All of them are provided into any mod
c ...)
ty))]))
;; wrap the original for with a type annotation
(define-syntax (for/annotation stx)
(syntax-parse stx
[(_ x ...)
(syntax/loc stx
(ann (for x ...) Void))]))
(define-syntax (for*/annotation stx)
(syntax-parse stx
[(_ x ...)
(syntax/loc stx
(ann (for* x ...) Void))]))
;; we need handle #:when clauses manually because we need to annotate
;; the type of each nested for
(define-syntax (for: stx)

View File

@ -2,7 +2,7 @@
(providing (libs (except racket/base #%module-begin #%top-interaction with-handlers lambda #%app define-struct)
(providing (libs (except racket/base #%module-begin #%top-interaction with-handlers lambda #%app define-struct for for*)
(except typed-scheme/private/prims)
(except typed-scheme/private/base-types)
(except typed-scheme/private/base-types-extra))
@ -18,5 +18,5 @@
(for-syntax typed-scheme/private/base-types-extra))
(provide (rename-out [with-handlers: with-handlers]
[define-type-alias define-type])
assert with-type
assert with-type for for*
(for-syntax (all-from-out typed-scheme/private/base-types-extra)))

View File

@ -2,7 +2,7 @@
(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app define-struct)
(providing (libs (except scheme/base #%module-begin #%top-interaction with-handlers lambda #%app define-struct for for*)
(except typed-scheme/private/prims)
(except typed-scheme/private/base-types)
(except typed-scheme/private/base-types-extra))
@ -18,5 +18,5 @@
(for-syntax typed-scheme/private/base-types-extra))
(provide (rename-out [with-handlers: with-handlers]
[define-type-alias define-type])
assert with-type
assert with-type for for*
(for-syntax (all-from-out typed-scheme/private/base-types-extra)))