elm-repl is a tool that lets us experiment with Elm. We will be using this tool extensively in the next chapter to learn the syntax and semantics of the Elm programming language. REPL stands for Read Eval Print Loop. It basically waits for us to enter some Elm code, evaluates it, prints out the result, and goes back to waiting for more code. This cycle repeats forever until we exit out of it by pressing
Ctrl + d.
elm-repl allows us to type Elm code and see the result immediately without having to compile it manually. The difference between
elm-repl is good for trying out short expressions as we explore the language whereas
elm-reactor is better for trying out a bigger piece of code that’s cumbersome to type in the repl.
Go to the
beginning-elm directory in the terminal and run this command:
elm-repl. You should see something like this:
We can now type all sorts of Elm expressions in here and find out what they evaluate to. Here are some examples:
All examples in the book are thoroughly tested with Elm 0.18. As you work through them, if you notice that the output produced by the repl doesn’t match what’s in the book, try re-starting the repl. Sometimes that fixes the issue. If not, please provide a helpful description of the issue you are experiencing in the comments section.