How to Install ELM

how to install elm

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

Node setup.

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
install elm

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.

vscodesetup

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.

reveal 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.

installation linux

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.
elm repl

Next Topic : Click Here

This Post Has One Comment

Leave a Reply