main = asText <| 3 `mod` 0
results in the error "Maximum call stack size exceeded", it seems like it should throw a nicer error like "Cannot divide by 0" (what Haskell does) or return NaN (what JavaScript does).
Actually, is NaN a valid Elm Int? It might be nice to better specify some of this, especially NaN and Infinity.
Running example: http://share-elm.com/sprout/523a9bf1e4b00f123dfa613e
Should throw an error now :) https://github.com/evancz/Elm/commit/46b988b34f3ae9518a9a91c0534b26b1cc87ba62
NaN and infinity are not a thing in Elm.
@evancz I trust you and I am pretty sure that you must've had a good reason to make a language with "no runtime exceptions" throw an error, but I just cannot seem to figure out why you decided to do this.
One can pretty easily create an example that crashes horribly because of this.
For example you could try this SSCCE: https://pastebin.com/jF5uYiYg in http://elm-lang.org/try
I mean, it's much better than infinite recursion, but still doesn't fit the description of the language.
Currently I don't really have any good idea for other choices on how to handle this, but in the meantime returning zero or simply the dividend could mitigate the case. I mean, it's version 0.18, so you don't really have to worry about these edge cases when considering backwards compatibility.
Maybe have a safe version which checks if the divisor is 0 and returns Nothing if that is the case. Similarly with modulo.