ELM – Environment Setup


Elm – Environment Setup


”;


This chapter discusses steps 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 TutorialsPoint 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 [email protected]

Install elm

After installation, execute the following command to verify the version of Elm.

C:Usersdell>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 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 Read 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 an 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

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *