Installing Elm on Ubuntu 14.04

Elm is a functional programming language for the web.


Elm lets you write programs in a simple functional language and it compiles to html, javascript and CSS. This sounded like a cool way to learn about FRP (Functional Reactive Programming), so I decided to give it a try.

Because it’s a young language (the thesis which gave it birth was in 2012) it’s evolving fast, so dependencies and syntax are still changing.

Installation #

We want to install the Elm-Platform which comes with all the tools to get started:

Starting with the right version #

To install Elm 0.15.1 you will need Haskell and Cabal (the Haskell package manager). Currently you need GHC 7.10 and at least cabal 1.18.

However installing them with apt-get on Ubuntu will install an older version which won’t work (cabal and ghc 7.6.3).

So the first thing is to get a more recent version of Cabal and ghc

sudo add-apt-repository ppa:hvr/ghc
sudo apt-get update

The packages install into /opt/ghc/$VER/ so in order to use them, the easiest way is to bring a particular GHC version into scope by placing the respective /opt/ghc/$VER/bin folder early into the PATH environment variable. See also for more information

sudo apt-get install ghc-7.10.1
sudo apt-get install cabal-install-1.22

and add it to your PATH variable (or add it to your .bashrc):

# Haskell & cabal Path
export PATH=/opt/ghc/7.10.1/bin:$PATH
export PATH=/opt/cabal/1.22/bin:$PATH

You should now see:

cabal --version
cabal-install version
using version of the Cabal library 
which cabal

The Elm Platform #

  1. chose a directory to save all the files for your installation (but don’t create a directory). Let’s assume we want it to live at ~/Documents/code/ (You should not move this directory after it is created, so choose carefully before progressing)
  2. add the absolute path Elm-Platform/0.15.1/.cabal-sandbox/bin to your PATH. For our example above, this would be:

$ export PATH=/home/user/Documents/code/Elm-Platform/0.15.1/.cabal-sandbox/bin:$PATH

or you can add it to .bashrc or .bash_profile as described here.

  1. Let’s go to the directory we selected (in our example $ cd ~/Documents/code), and run the haskell installation file:
# if you are on windows, or some other place without curl, just download this file manually

curl > BuildFromSource.hs

runhaskell BuildFromSource.hs 0.15.1

You can test if your installed version is right with:

$ elm-make --help
elm-make 0.2 (Elm Platform 0.15.1)


$ which elm-make

Let’s try it out: #

let’s create a new directory, mkdir helloworld && cd helloworld and create a helloworld.elm file.

-- helloworld.elm
import Html exposing (text)
main =
  text "Hello, World!"

you can compile it with elm-make which should create 3 files:

elm-package.json elm-stuff helloworld.elm

and check out the result in the browser with:

Elm Reactor 0.3.2 (Elm Platform 0.15.1)
Listening on

Have fun!


Now read this

Entrepreneurship is Juggling

Being the founder of a startup means juggling more tasks and domains than you ever thought possible. I’ll share my mental storm in the last 3 days … for those who are considering the startup life. At renooble we are 2 people, and we are... Continue →