This chapter discusses how to install Elm on Windows, Mac, and Linux platforms.
Local Environment Setup
Consider the steps shown below to install Elm in your local environment.
Step 1 β Install node
Since elm is compiled to JavaScript, the target machine should have node installed. Refer to Adglob’s NodeJS course for steps to setup node and npm
Step 2 β Install elm
Execute the following command on the terminal to install elm. Note that the stable version of elm was 0.18 at the time of writing this course.
npm install -g elm@0.18
After installation, execute the following command to verify the version of Elm.
C:\Users\dell>elm --version 0.18.0
Step 2 β Install the Editor
The development environment used here is Visual Studio Code (Windows platform).
Visual Studio Code is an open source IDE from Visual Studio. It is available for Mac OS X, Linux, and Windows platforms. VSCode is available at
https://code.visualstudio.com/.
Installation on Windows
In this section, we will discuss the steps to install Elm on Windows.
Download https://code.visualstudio.com/. for Windows.
Double-click on VSCodeSetup.exe to launch the setup process. This will only take a minute.
You may directly traverse to the fileβs path by right clicking on File β Open in the command prompt. Similarly, the Reveal in Explorer option shows the file in the File Explorer.
Installation on Mac OS X
Visual Studio Codeβs Mac OS X-specific installation guide can be found at VSCode Installation-MAC.
Installation on Linux
Visual Studio Codeβs Linux specific installation guide can be found at VSCode Installation-Linux.
Step 4 β Install the elm Extension
Install the elm extension in VSCode as shown below.
Elm REPL
REPL stands for reading Eval Print Loop. It represents a computer environment like a Windows console or Unix/Linux shell where a command is entered and the system responds with output in an interactive mode.
Elm comes bundled with a REPL environment. It performs the following tasks β
- Read β Reads user’s input, parses the input into elm data-structure, and stores in memory.
- Eval β Takes and evaluates the data structure.
- Print β Prints the result.
- Loop β Loops the above command until the user exits. Use the command :exit to exit REPL and return to the terminal.
A simple example to add two numbers in REPL is shown below β
Open the VSCode terminal and type the command elm REPL.
The REPL terminal waits for the user to enter some input. Enter the following expression 10 + 20. The REPL environment processes the input as given below β
- Reads numbers 10 and 20 from user.
- Evaluates using the + operator.
- Prints result as 30.
- Loops for next user input. Here we exit from loop.
Next Topic : Click Here
Pingback: Elm - Introduction | Adglob Infosystem Pvt Ltd