From c9a96c1d2c49e87ebbc26e837edf563b359f8c57 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Thu, 10 Jun 2010 13:58:41 -0400 Subject: [PATCH] Added some closure and promotion type signatures. --- .../typed-scheme/private/base-env-numeric.rkt | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/collects/typed-scheme/private/base-env-numeric.rkt b/collects/typed-scheme/private/base-env-numeric.rkt index f0ccb7235a..56885801a0 100644 --- a/collects/typed-scheme/private/base-env-numeric.rkt +++ b/collects/typed-scheme/private/base-env-numeric.rkt @@ -62,7 +62,8 @@ [odd? (-> -Integer B)] [even? (-> -Integer B)] -[modulo (cl->* (-Integer -Integer . -> . -Integer))] +[modulo (cl->* (-Nat -Nat . -> . -Nat) + (-Integer -Integer . -> . -Integer))] [= (->* (list N N) N B)] @@ -81,34 +82,28 @@ [* (apply cl->* (append (for/list ([t (list -Pos -Nat -Integer -ExactRational -Flonum)]) (->* (list) t t)) - (list (->* (list (Un -Integer -ExactRational -Real -Flonum)) - (Un -Integer -ExactRational -Real -Flonum) - -Flonum)) (list (->* (list) -Real -Real)) (list (->* (list) N N))))] [+ (apply cl->* (append (for/list ([t (list -Pos -Nat -Integer -ExactRational -Flonum)]) (->* (list) t t)) - (list (->* (list (Un -Integer -ExactRational -Real -Flonum)) - (Un -Integer -ExactRational -Real -Flonum) - -Flonum)) + ;; special cases for promotion to inexact, not exhaustive + ;; valid for + and -, but not for * and /, since (* 0) is exact 0 (i.e. not a float) + (list (->* (list -Flonum) -Real -Flonum)) + (list (->* (list -Real -Flonum) -Real -Flonum)) (list (->* (list) -Real -Real)) (list (->* (list) N N))))] [- (apply cl->* (append (for/list ([t (list -Integer -ExactRational -Flonum)]) (->* (list t) t t)) - (list (->* (list (Un -Integer -ExactRational -Real -Flonum)) - (Un -Integer -ExactRational -Real -Flonum) - -Flonum)) + (list (->* (list -Flonum) -Real -Flonum)) + (list (->* (list -Real -Flonum) -Real -Flonum)) (list (->* (list -Real) -Real -Real)) (list (->* (list N) N N))))] [/ (apply cl->* (append (list (->* (list -Integer) -Integer -ExactRational)) (for/list ([t (list -ExactRational -Flonum)]) (->* (list t) t t)) - (list (->* (list (Un -Integer -ExactRational -Real -Flonum)) - (Un -Integer -ExactRational -Real -Flonum) - -Flonum)) (list (->* (list -Real) -Real -Real)) (list (->* (list N) N N))))] @@ -169,7 +164,8 @@ [log (cl->* (-Pos . -> . -Real) (N . -> . N))] -[exp (N . -> . N)] +[exp (cl->* (-Real . -> . -Real) + (N . -> . N))] [cos (cl->* (-Flonum . -> . -Flonum) (-Real . -> . -Real) (N . -> . N))] [sin (cl->* (-Flonum . -> . -Flonum) (-Real . -> . -Real) (N . -> . N))] [tan (cl->* (-Flonum . -> . -Flonum) (-Real . -> . -Real) (N . -> . N))]