Typecheck prompt tags

original commit: 4b5d6e71fdfe68dea748b296c4427209d54a920f
This commit is contained in:
Asumu Takikawa 2012-11-02 15:20:45 -04:00
parent 5069b7b9b9
commit 6f376407d9
5 changed files with 29 additions and 8 deletions

View File

@ -38,6 +38,7 @@
make-CustodianBox
make-HeterogeneousVector
make-Continuation-Mark-Key
make-Prompt-Tag
make-ListDots))
;Section 9.2
@ -593,6 +594,7 @@
(make-ListDots a 'a)
(-values (list (-pair b (-val '())) -Nat -Nat -Nat)))))]
[call/cc (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (Un a b)))]
[call/ec (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (Un a b)))]
[call-with-current-continuation (-poly (a b) (((a . -> . (Un)) . -> . b) . -> . (Un a b)))]
@ -2023,9 +2025,22 @@
[call-with-continuation-barrier (-poly (a) (-> (-> a) a))]
[continuation-prompt-available? (-> -Prompt-Tag B)]
[make-continuation-prompt-tag (->opt [Sym] -Prompt-Tag)]
[default-continuation-prompt-tag (-> -Prompt-Tag)]
[continuation-prompt-tag? (make-pred-ty -Prompt-Tag)]
[call-with-continuation-prompt
(-polydots (a b d c)
(cl->*
(-> (-> b) (make-Prompt-Tag b (->... '() (c c) d)) (->... '() (c c) d)
(Un b d))
(-> (-> b) Univ)))]
[abort-current-continuation
(-polydots (a b d e c)
(->... (list (make-Prompt-Tag b (->... '() (c c) d))) (c c) e))]
[call-with-composable-continuation
(-polydots (b c a)
(cl->*
(-> (->... '() (a a) b) (make-Prompt-Tag b c) (make-ValuesDots '() a 'a))))]
[make-continuation-prompt-tag (-poly (a b) (->opt [Sym] (make-Prompt-Tag a b)))]
[default-continuation-prompt-tag (-> (make-Prompt-Tag Univ (-> ManyUniv Univ)))]
;[continuation-prompt-tag? (make-pred-ty -Prompt-Tag)]
[dynamic-wind (-poly (a) (-> (-> ManyUniv) (-> a) (-> ManyUniv) a))]
;Section 9.5 (Continuation Marks)

View File

@ -143,7 +143,6 @@
[Place-Channel -Place-Channel]
[Place -Place]
[Will-Executor -Will-Executor]
[Prompt-Tag -Prompt-Tag]
[Listof -Listof]
@ -170,4 +169,5 @@
[Thread-Cellof (-poly (a) (-thread-cell a))]
[Custodian-Boxof (-poly (a) (make-CustodianBox a))]
[Continuation-Mark-Key (-poly (a) (make-Continuation-Mark-Key a))]
[Continuation-Mark-Key (-poly (a) (make-Continuation-Mark-Key a))]
[Prompt-Tag (-poly (a b) (make-Prompt-Tag a b))]

View File

@ -342,6 +342,10 @@
[(Continuation-Mark-Key: t)
(set-chaperone!)
#`(continuation-mark-key/c #,(t->c t))]
;; TODO: this is not quite right for case->
[(Prompt-Tag: s (Function: (list (arr: (list ts ...) _ _ _ _))))
(set-chaperone!)
#`(prompt-tag/c #,@(map t->c ts) #:call/cc #,(t->c s))]
;; TODO
[(F: v) (cond [(assoc v (vars)) => second]
[else (int-err "unknown var: ~a" v)])]

View File

@ -415,9 +415,9 @@
;; prompts with this tag will return a union of `body`
;; and the codomains of `handler`
(def-type Prompt-Tag ([body Type/c] [handler Function?])
[#:key 'prompt-tag]
[#:frees (λ (f) (combine-frees (make-invariant (f body))
(make-invariant (f handler))))])
[#:frees (λ (f) (combine-frees (list (make-invariant (f body))
(make-invariant (f handler)))))]
[#:key 'prompt-tag])
;; value: the type of allowable values
(def-type Continuation-Mark-Key ([value Type/c])

View File

@ -281,6 +281,8 @@
[(Hashtable: k v) (fp "(HashTable ~a ~a)" k v)]
[(Continuation-Mark-Key: rhs)
(fp "(Continuation-Mark-Key ~a)" rhs)]
[(Prompt-Tag: body handler)
(fp "(Prompt-Tag ~a ~a)" body handler)]
#;[(Poly-unsafe: n b) (fp "(unsafe-poly ~a ~a ~a)" (Type-seq c) n b)]
[(Poly-names: names body)
#;(eprintf "POLY SEQ: ~a\n" (Type-seq body))