Improve type of exact? and exact->inexact.

Adapted from a pull request by Eric Dobson.

original commit: 0bc60a77c86499186fdf8087621191183104b10f
This commit is contained in:
Vincent St-Amour 2013-01-29 12:34:46 -05:00
parent e68c287705
commit 02ad4095fa
2 changed files with 7 additions and 3 deletions

View File

@ -215,6 +215,7 @@
(tc-e (min (ann 3 Fixnum) (ann 3 Fixnum)) -Fixnum)
(tc-e (min (ann -2 Negative-Fixnum) (ann 3 Fixnum)) -NegFixnum)
(tc-e (min (ann 3 Fixnum) (ann -2 Negative-Fixnum)) -NegFixnum)
(tc-e (exact->inexact (ann 3 Number)) (t:Un -InexactReal -InexactComplex))
[tc-e/t (lambda: () 3) (t:-> -PosByte : -true-lfilter)]
[tc-e/t (lambda: ([x : Number]) 3) (t:-> N -PosByte : -true-lfilter)]

View File

@ -697,8 +697,11 @@
[complex? (make-pred-ty N)]
;; `rational?' includes all Reals, except infinities and NaN.
[rational? (asym-pred Univ B (-FS (-filter -Real 0) (-not-filter -Rat 0)))]
[exact? (asym-pred N B (-FS -top (-not-filter -Rat 0)))]
[inexact? (asym-pred N B (-FS -top (-not-filter (Un -InexactReal -FloatComplex) 0)))]
[exact? (asym-pred N B (-FS -top (-not-filter -ExactNumber 0)))]
;; `inexact?' can't be a predicate for `(Un -InexactReal -InexactComplex)' because it
;; returns #t on things like 0+1.2i, which are not -InexactComplex (`real-part' of it
;; is exact 0)
[inexact? (asym-pred N B (-FS -top (-not-filter (Un -InexactReal -InexactComplex) 0)))]
[fixnum? (make-pred-ty -Fixnum)]
[index? (make-pred-ty -Index)]
[positive? (cl->* (-> -Byte B : (-FS (-filter -PosByte 0) (-filter -Zero 0)))
@ -1501,7 +1504,7 @@
(-FloatComplex . -> . -FloatComplex)
(-SingleFlonumComplex . -> . -SingleFlonumComplex)
(-InexactComplex . -> . -InexactComplex)
(N . -> . N))]
(N . -> . (Un -InexactReal -InexactComplex)))]
[inexact->exact
(from-cases (map unop all-rat-types)
(-RealZero . -> . -Zero)