From 8d95570bcbd0380f6b9a6b36c8350be6bfbacdf6 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Fri, 9 Jul 2010 17:29:48 -0400 Subject: [PATCH] Added types for sequence functions. original commit: 4a8113eac6adfd68533a0a134ba8b1434846da97 --- .../typed-scheme/private/base-special-env.rkt | 63 ++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/collects/typed-scheme/private/base-special-env.rkt b/collects/typed-scheme/private/base-special-env.rkt index a643b158..02c33f62 100644 --- a/collects/typed-scheme/private/base-special-env.rkt +++ b/collects/typed-scheme/private/base-special-env.rkt @@ -171,7 +171,68 @@ (-> Univ (-vec a) (seq-vals)) (-> Univ -String (seq-vals -Char)) (-> Univ -Bytes (seq-vals -Nat)) - (-> Univ -Input-Port (seq-vals -Nat)))))]) + (-> Univ -Input-Port (seq-vals -Nat)))))] + ;; in-range + [(syntax-parse (local-expand #'(in-range 1) 'expression #f) + [(i-n _ ...) + #'i-n]) + (cl->* (-PositiveFixnum -Fixnum [-Nat] . ->opt . (-seq -PositiveFixnum)) + (-NonnegativeFixnum [-Fixnum -Nat] . ->opt . (-seq -NonnegativeFixnum)) + (-Fixnum [-Fixnum -Integer] . ->opt . (-seq -Fixnum)) + (-ExactPositiveInteger -Integer [-Nat] . ->opt . (-seq -ExactPositiveInteger)) + (-Nat [-Integer -Nat] . ->opt . (-seq -Nat)) + (-Integer [-Integer -Integer] . ->opt . (-seq -Integer)))] + ;; in-naturals + [(syntax-parse (local-expand #'(in-naturals) 'expression #f) + [(i-n _ ...) + #'i-n]) + (cl->* (-> -ExactPositiveInteger (-seq -ExactPositiveInteger)) + (-> -Integer (-seq -Nat)))] + ;; in-list + [(syntax-parse (local-expand #'(in-list '(1 2 3)) 'expression #f) + [(i-n _ ...) + #'i-n]) + (-poly (a) (-> (-lst a) (-seq a)))] + ;; in-vector + [(syntax-parse (local-expand #'(in-vector (vector 1 2 3)) 'expression #f) + [(i-n _ ...) + #'i-n]) + (-poly (a) (->opt (-vec a) [-Integer (-opt -Integer) -Integer] (-seq a)))] + ;; in-string + [(syntax-parse (local-expand #'(in-string "abc") 'expression #f) + [(i-n _ ...) + #'i-n]) + (->opt -String [-Integer (-opt -Integer) -Integer] (-seq -Char))] + ;; in-bytes + [(syntax-parse (local-expand #'(in-bytes #"abc") 'expression #f) + [(i-n _ ...) + #'i-n]) + (->opt -Bytes [-Integer (-opt -Integer) -Integer] (-seq -Byte))] + ;; in-port + [(syntax-parse (local-expand #'(in-port) 'expression #f) + [(i-n _ ...) + #'i-n]) + (->opt [(-> -Input-Port Univ) -Input-Port] (-seq Univ))] + ;; in-input-port-bytes + [(syntax-parse (local-expand #'(in-input-port-bytes (open-input-bytes #"abc")) 'expression #f) + [(i-n _ ...) + #'i-n]) + (-> -Input-Port (-seq -Byte))] + ;; in-input-port-chars + [(syntax-parse (local-expand #'(in-input-port-chars (open-input-string "abc")) 'expression #f) + [(i-n _ ...) + #'i-n]) + (-> -Input-Port (-seq -Char))] + ;; in-lines + [(syntax-parse (local-expand #'(in-lines) 'expression #f) + [(i-n _ ...) + #'i-n]) + (->opt [-Input-Port -Symbol] (-seq -String))] + ;; in-bytes-lines + [(syntax-parse (local-expand #'(in-bytes-lines) 'expression #f) + [(i-n _ ...) + #'i-n]) + (->opt [-Input-Port -Symbol] (-seq -Bytes))])