typed-racket
typed-racket copied to clipboard
Is there no way to specify non-NaN flonum types?
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
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.