This is an example how we can break an Elm program from the outside by messing with its stuff in unexpected ways.
Compile using elm make Main.elm --output=main.js
and open index.html
in a browser.
Write something into the text field. The text will get reversed and on every character the counter counts up. Click the button and you'll see it counts up as well.
Looking at the Elm source file, this program can't crash or otherwise suddenly start to misbehave, right?
Well, let's see.
Now enter PWN3D
into the text field.
From now on, the program is broken entirely. Writing any character will throw an uncaught error nope
from inside
Elm which you can see in the browser devtools.
Even worse, clicking the button will now cause Elm to emit a loop of uncaught errors many times a second.