From 9b7ee99d39ae445fe440a879001c421fca8a87da Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Mon, 28 Jun 2010 20:13:21 -0400 Subject: [PATCH] Extended type signatures for addition. original commit: e8c42cd20cc00e607e44bb6f172333d49b8a707d --- collects/typed-scheme/private/base-env-numeric.rkt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/collects/typed-scheme/private/base-env-numeric.rkt b/collects/typed-scheme/private/base-env-numeric.rkt index 75d8e56c..614a8723 100644 --- a/collects/typed-scheme/private/base-env-numeric.rkt +++ b/collects/typed-scheme/private/base-env-numeric.rkt @@ -97,7 +97,9 @@ (list (->* (list) -InexactComplex -InexactComplex)) (list (->* (list) N N))))] [+ (apply cl->* - (append (for/list ([t (list -Pos -Nat -Integer -ExactRational -Flonum)]) (->* (list) t t)) + (append (list (->* (list -Pos) -Nat -Pos)) + (list (->* (list -Nat) -Pos -Pos)) + (for/list ([t (list -Nat -Integer -ExactRational -Flonum)]) (->* (list) t t)) ;; 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)) @@ -311,7 +313,10 @@ [unsafe-flsqrt fl-unop] [unsafe-fx->fl (-Integer . -> . -Flonum)] -[unsafe-fx+ fx-op] +[unsafe-fx+ (cl->* (-Pos -Nat . -> . -PositiveFixnum) + (-Nat -Pos . -> . -PositiveFixnum) + (-Nat -Nat . -> . -NonnegativeFixnum) + (-Integer -Integer . -> . -Fixnum))] [unsafe-fx- fx-intop] [unsafe-fx* fx-op] [unsafe-fxquotient fx-intop] @@ -336,7 +341,10 @@ ;; scheme/fixnum -[fx+ fx-op] +[fx+ (cl->* (-Pos -Nat . -> . -PositiveFixnum) + (-Nat -Pos . -> . -PositiveFixnum) + (-Nat -Nat . -> . -NonnegativeFixnum) + (-Integer -Integer . -> . -Fixnum))] [fx- fx-intop] [fx* fx-op] [fxquotient fx-intop]