Note: If you do not want to install yet, you can follow along anyway. Most sections can be done in an online editor!

Install

After installing through any of those routes, you will have the elm binary available in your terminal!

Troubleshooting: The fastest way to learn anything is to talk with other people in the Elm community. We are friendly and happy to help! So if you get stuck during installation or encounter something weird, visit the Elm Slack and ask about it. In fact, if you run into something confusing at any point while learning or using Elm, come ask us about it. You can save yourself hours. Just do it!

Configure Your Editor

Using Elm is way nicer when you have a code editor to help you out. There are Elm plugins for at least the following editors:

If you do not have an editor at all, Sublime Text is a great one to get started with!

You may also want to try out elm-format which makes your code pretty!

Terminal Tools

So we have this elm binary now, but what can it do exactly?

elm repl

elm repl lets us interact with Elm expressions in the terminal.

$ elm repl
---- Elm 0.19.0 ----------------------------------------------------------------
Read <https://elm-lang.org/0.19.0/repl> to learn more: exit, help, imports, etc.
--------------------------------------------------------------------------------
> 1 / 2
0.5 : Float
> List.length [1,2,3,4]
4 : Int
> String.reverse "stressed"
"desserts" : String
> :exit
$

We will be using elm repl in the upcoming “Core Language” section, and you can read more about how it works here.

Note: elm repl works by compiling code to JavaScript, so make sure you have Node.js installed. We use that to evaluate code.

elm reactor

elm reactor helps you build Elm projects without messing with the terminal too much. You just run it at the root of your project, like this:

git clone https://github.com/evancz/elm-architecture-tutorial.git
cd elm-architecture-tutorial
elm reactor

This starts a server at http://localhost:8000. You can navigate to any Elm file and see what it looks like. Try to check out examples/01-button.elm.

elm make

elm make builds Elm projects. It can compile Elm code to HTML or JavaScript. It is the most general way to compile Elm code, so if your project becomes too advanced for elm reactor, you will want to start using elm make directly.

Say you want to compile Main.elm to an HTML file named main.html. You would run this command:

elm make Main.elm --output=main.html

elm install

Elm packages all live at package.elm-lang.org.

Say you look around and decide you need elm/http and elm/json to make some HTTP requests. You can get them set up in your project with the following commands:

elm install elm/http
elm install elm/json

This will add the dependencies into your elm.json file, described in more detail here.

Summary

The elm binary can do a bunch of stuff. Do not worry about remembering it all. You can always just run elm --help or elm repl --help to get a bunch of information about any of these commands.

Next we are going to learn the basics of Elm!

results matching ""

    No results matching ""