Why is `NaN` a possible value for type `Int` in Elm?

Viewed 529

I recently started learning Elm. When I saw the Int type I assumed it was something like Haskell's Int, which is (I think) a machine integer.

But I was surprised to see this:

> Result.withDefault 0 <| String.toInt "-"
NaN : Int

NaN is a floating point concept which seems like it shouldn't apply to integers. It seems like this might be leaking in from JS, which would imply that Int is represented as a JS Number.

Is that the case? Why was this design decision made, and where can I go to learn about it?

(Also, two minor questions:

)

2 Answers

Answering second minor question (that's horrible it's still not outdated) NaN seems to be the only x such that x /= x

Related