Haskell at Work


I've recently (in blog years) started a new job at a company which uses Haskell quite extensively. Here are some things we do with it. Posted by Thomas Sutton on January 28, 2015

I recently (nearly 7 months ago) started work at Anchor Hosting as a software developer in the engineering department. Anchor is a hosting company, and its engineering group works on a variety of different things like time-series data storage and analysis, APIs and automation, business applications, and development tools.

I’ll describe some of our development tooling in this post and leave discussion of the “real” systems we work on for a later post.

Building and deploying

Given we’re a Haskell shop, we’ve needed to figure out how to build, deploy, and manage systems written in Haskell. I’m still not sold on the whole containerisation mania which seems to be sweeping certain parts of the IT world (and certainly not for general purpose multi-tenancy). Nevertheless, we’re finding Docker quite useful.

We have a Docker image containing GHC and cabal configured to use the Stackage package set, with a bunch of frequently used Haskell packages already installed. This image is built automatically using a small set of scripts.

Most of the systems we build operate as services (HTTP servers, agents on message queue, etc.) and we “package” them as Docker images too. We have another set of scripts which use the Haskell image to build a cabal package, extract the artefacts, and stuff them into a new Docker image. This approach results in an image which is significantly smaller than it otherwise would be.

Both sets of scripts can be used manually but they are also used in Jenkins jobs. Like everything mentioned so far Jenkins and its builders all run in Docker too, so we also have some scripts to build Jenkins Docker images.

All of these Docker images are run on CoreOS servers hosted on Anchor OpenCloud, Anchor’s new OpenStack deployment. Generally, we run each service as a Docker container managed by a systemd unit with its configuration and data files (such as they are) mounted in from the host file system. Each systemd unit deletes any old container and pulls the latest image before starting the service, so upgrading an instance is easy: just restart the systemd unit.

Development tools

Various members of the team all use different operating systems (various flavours of BSD, Linux, and Mac OS X), editors (vim, emacs, Sublime Text) and have different opinions and habits about coding style, etc. To help manage improve the consistency and, hopefully, quality of our code, we developed git-vogue. git-vogue runs as a pre-commit hook (currently for git, but it can be extended) and runs a range of checks over the modified or, optionally, all files in the repository. This isn’t perfect but has helped improve our code quite considerably.

This post was published on January 28, 2015 and last modified on January 26, 2024. It is tagged with: haskell, functional programming, work.