Haskell and Servant on Scaleway ARM servers

A while back, scaleway announced some very affordable bare metal servers: for €3 a month you get 4 (ARM) cores, 2GB of RAM, and a 50GB SSD.

I’ve wanted to try out ARM in the server room for some time, and I wanted a chance to use the fantastic servant library, so I’ve built an example REST API and web-app using servant and deployed it on scaleway. You can see the demo running here.

This blog post is about how to get compiling with a modern (7.10) GHC on a Scaleway ARM server running their stock Ubuntu 15.04 image. A better solution might be cross-compiling, but this is a simple-ish way to get Haskell/Servant code running on Scaleway.


First, a quick summary of the demo.

The demo is a simple messageboard, consisting of only threads and comments. It serves endpoints as either JSON or HTML, so you can view content through your browser. I didn’t bother adding HTML forms, so to add comments or threads, you’ll need to make a POST request yourself. Check out the example curl scripts in the the github repo.

A note on quality: the demo isn’t very well written- it’s the first thing I made with servant. If you’re looking for servant examples, you should go to the official docs.

Getting GHC 7.10 on Scaleway’s Ubuntu 15.04 Image

I used GHC 7.10.2, which you can download here. I’ll refer to it below by something like <ghc_arm_package.tar.xz> instead of its full name.

Here’s what you need to do to run the demo:

Update your system, and install git:

apt-get update
apt-get upgrade
apt-get install git

Install GHC dependencies- LLVM is for GHC 7.10.2

apt-get install llvm-3.5 binutils gcc g++ zlib1g-dev libgmp-dev`

Install cabal-install - this uses GHC 7.6.3 for now

apt-get install cabal-install

Install GHC 7.10

wget <ghc_arm_package.tar.xz>
tar xf <ghc_arm_package.tar.xz>
cd <ghc_arm_package>
make install

At this point, GHC 7.10 should be installed. Verify that ghc --version prints 7.10.2.

Update cabal-install so we can use sandboxes

cabal update
cabal install cabal-install

Run the code

git clone
cd scaleway-servant-demo
cabal sandbox init && cabal install --only-dependencies
cabal run

You should now be able to run the example curl scripts to populate the demo with some fake data, e.g.:



Things went pretty smoothly in general, but I did encounter a couple of minor hiccups:

  1. Compiling is pretty slow on these boxes. That said, I’m comparing against my laptop, which has an i5 and 16GB of RAM. It also uses binary distributions of haskell packages, so I don’t really have a fair comparison :-)

  2. I saw cabal/GHC run out of memory once, while trying to compile too many packages simultaneously.

These aren’t really huge problems. In a production setting you’d probably be running a CI server. That could be an ARM server, or a cross compiler running on x86. This at least shows that Haskell on ARM is not too hard :-)

Final Thoughts

It’s dead easy to get a machine running on Scaleway. Their UI is simple, and it takes only a few clicks to get a machine running. I’m not really sure what kind of projects would be well suited to Scaleway boxes, but at €3 you might as well play around with one!