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:
NaN a valid literal?Int value isn't a NaN? The function isNaN is of type Float -> Bool http://package.elm-lang.org/packages/elm-lang/core/latest/Basics#isNaN
)
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.
Answering second minor question (that's horrible it's still not outdated) NaN seems to be the only x such that x /= x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With