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

Recently, I began to study Elm. When I saw the type Int, I assumed that it was something like Haskell Int, which (I think) is an integer.

But I was surprised to see this:

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

NaN- A floating-point concept that does not seem to apply to integers. It looks like it could be a leak from JS, which implies that it Intappears to be JS Number.

This is true? Why was this design decision made, and where can I find out about it?

(In addition, two minor questions:

)

+4
source share
1 answer

NaNis not a valid value Int. This is a bug in a package elm-lang/corethat has been fixed on the main but not yet released.

+5
source

Source: https://habr.com/ru/post/1680559/


All Articles