[racket] TR: predicate for a Float ?

From: John Clements (clements at brinckerhoff.org)
Date: Thu Jan 5 19:00:38 EST 2012

I'd like a predicate that checks whether a number is a Float. Here's what I tried:

         (: amplitudes/t (Listof Float))
         (define amplitudes/t
           (cond [(andmap inexact-real? amplitudes)
                 [(error 'impossible "Make TR happy")]))

But I get:

Type Checker: Expected Coefficients, but got (U Null (Pairof Inexact-Real (Listof Inexact-Real))) in: amplitudes

Examining the difference between Inexact-Real and Float yields this:

> (:type Float)
(U Float-Positive-Zero Float-Negative-Zero Float-Nan Positive-Float Negative-Float)
> (:type Inexact-Real)
(U Float-Positive-Zero Float-Negative-Zero Float-Nan Positive-Float Negative-Float Single-Flonum-Positive-Zero Single-Flonum-Negative-Zero Single-Flonum-Nan Positive-Single-Flonum Negative-Single-Flonum)

...which actually made me laugh out loud.  Is there a predicate I can use instead of 'inexact-real?' that checks whether a number belongs to the type Float?

(The larger picture here is that TR *had* this type information--namely, that amplitudes is a (Listof Float), but it looks like it's getting lost by an overly-complex expansion of match.)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4624 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20120105/9dadb283/attachment.p7s>

Posted on the users mailing list.