7
votes

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
It seems to be fixed in 0.19 - radrow

2 Answers

9
votes

NaN isn't a valid Int value. It's a bug in the elm-lang/core package which has since been fixed on master, but hasn't been released yet.

1
votes

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