typed-racket icon indicating copy to clipboard operation
typed-racket copied to clipboard

Is there no way to specify non-NaN flonum types?

Open Aeva opened this issue 3 years ago • 1 comments

What version of Racket are you using?

8.0

What program did you run?

(:type #:verbose Positive-Float) prints (U Float-Nan Positive-Float-No-NaN), which is odd because (positive? +nan.0) returns #f.

(:type Positive-Float-No-NaN) throws an error claiming Positive-Float-No-NaN is unbound. As far as I can tell, under no circumstance does Positive-Float-No-NaN appear to be a valid type that I can use 😭 .

What should have happened?

It seems like Positive-Float-No-NaN should be a type? I've been digging through the docs for hours trying to work out a way to specify a Non-NaN float as a type, and it just doesn't seem to be possible???????

Also the mismatch between Positive-Float and positive? is weird, but it looks like this is a known issue (see #750).

If you got an error message, please include it here.

. Type Checker: parse error in type;
 type name `Positive-Float-No-NaN' is unbound in: Positive-Float-No-NaN

Aeva avatar Apr 23 '21 04:04 Aeva

I agree that the printing/input difference is a bug. And #750 should probably be fixed.

However, non-NaN types are basically useless in our experience, and the fact that there's a distinction in the type system is a historical legacy. Effectively no operations can be shown to preserve lack-of-NaN without much fancier reasoning than TR does. When we had specifications of what could produce NaN, they were always buggy, and that's why we got rid of them.

samth avatar Apr 23 '21 12:04 samth