Elm has two types which hold numbers: Int and Float. I think the system of number types in Elm needs improvement (I made 2 posts that are somewhat related to this).
One problem is that there needs to be a more explicit distinction between Int and Float. This includes the syntax for number literals, where there is sometimes no difference between Int an Float. Maybe there should be a syntax in number literals where 3.i
is an integer and 3.f
is a float. There should also be more explicit separation of the arithmetic operators. One time I saw someone’s idea where they proposed that things like +.
would be for floats (I can’t find the post).
Another problem is the ability to remove impossible states in number values. You are forced to have numbers be able to hold a very wide range of numbers. This does not allow you to remove impossible values from numbers. There are packages that try to solve this problem, but they don’t provide enough control. For example, if you have a predefined number value that needs to be within a certain range, but the number you set is out of range, it does not produce a compile error.
This is a great description of how to think about removing impossible states. It says this:
Int
is the set{ ... -2, -1, 0, 1, 2 ... }
But what if we want it to just be { 0, 1, 2, 3, ... }
? There is no way to do that currently.
It also needs to be possible to define 8 bit ints, 16 bit int, etc. because that will be useful in the future if Elm ever is able to compile to WebAssembly.
This is a very difficult language design problem to solve. Do you have any ideas for solving this prob?