Reading roc-for-elm-programmers.md
, the only thing I could find about runtime exceptions is the numeric overflow. Are panic/aborts exposed to the app code anywhere else?
In roc, if there is a panic, it is sent directly to the platform/host and the app doesn't see it. Otherwise an error is returned to the app. Like in the case of getting an element from a list, you can receive an error that the index was out of bounds
The distinction is essentially recoverable vs unrecoverable errors. In some cases, you can opt into recieving an error instead of panicing. For example, doing an addition that explicitly checks for overflow.
Of course, when a host receives a panic, it doesn't have to crash. It can just clean up and continue executing.
In the example of addition, these are "throwing" vs result-ing functions, right?
Also, is there like a "panic" or "abort" function available in userspace?
there is not, though I guess you could just cause an overflow and that would cause a panic and control is given to the platform
Ah! So, runtime exceptions really are just effects, albeit implicit.
That is a very interesting way to word it...but I guess.
Shritesh Bhattarai has marked this topic as resolved.
Last updated: Jul 06 2025 at 12:14 UTC