@rupert,
As per your examples and many more, yes, these things should have been fixed many versions ago and the pain of the breaking changes undergone there. This is at least one area that any new language SHOULDN’T be backwards compatible with current Elm.
the bit shifting operators only acting on the first 32 (bits - GBG)
I think this was an error in specification on Evan’s part, as integers that are treated as true 32-bit integers as in taking four bytes in all current JavaScript engines are the only Int
’s and Evan’s sometimes treating JavaScript 64-bit floating point numbers as Float’s and sometimes as Int’s is inconsistent when used by JavaScript bitwise operations which only work on 32 bits.
F#/Fable, which support the whole gamut of integer and float types, gets it right although it doesn’t have type classes and only somewhat override-able operators, in that it matches on all the available types, BUT it requires that all numeric type literals other than default float64 numbers with a decimal point and int32 numbers without a decimal point have a number suffix to match the required operator type. With this, re-factoring to a different number type is tedious in having to change all the suffixes. Fable also supports 64-bit integers (and maybe 128-bit ones to come) by emulation in JavaScript, and also has a BitNum integer type that can be sometimes useful; Roc doesn’t have the latter, at least not yet.
Haskell also supports all the number types and type classes, but whenever a required type doesn’t match the inferred type, one has to type match by the use of frequent fromintegral
numeric casting functions.
Roc is more similar to Haskell than not in this regard, with the full range of numeric types that are generally automatically inferred by preference but there are casting functions available to be able to mix types AND also numeric type suffixes to by able to force a type when desired (not recommended in the documentation). I think this is a workable solution.
Not sure if a proliferation of number types like Roc is a good idea or not. Perhaps Elm might be improved by making Int an arbitrary precision integer implementation, and keeping Float standardized on F64 (IEEE except that different browsers handle that differently).
If one wants a general purpose language, then I don’t think there is any choice but to support the proliferation of types, and by making float64 the default floating point and int32 the default integer, it is as compatible as possible. This works for F#/Fable.
how we can get there with minimal disruption.
There will be some breaking changes adopting the above, but not too many in production code as THE EXISTING ELM SPEC IS NOT CORRECT. A new Elm-like language must be mathematically correct and type sound, which current Elm is not in this regard.