Haskell on Heroku Tutorial

A step-by-step guide to deploying Haskell apps on Heroku.

Overview

Follow the Haskell on Heroku tutorial to get started. The buildpack installs the Haskell toolchain, including GHC and Cabal, and produces a runnable application that Heroku can launch with a standard Procfile.

Prerequisites

  • A Heroku account and the Heroku CLI installed locally.
  • Git, configured and signed in.
  • A Haskell project with a .cabal file and an executable target.

Step-by-step

  1. From your project root, log in and create a new Heroku app, setting this buildpack during creation:
    heroku login
    heroku create
    heroku buildpacks:set https://github.com/mietek/haskell-on-heroku.git
  2. Commit your project and push it to Heroku:
    git add .
    git commit -m "Deploy Haskell app to Heroku"
    git push heroku main
  3. Open the app once the build finishes:
    heroku open

The buildpack can also be used when creating a new Heroku app alongside any other Heroku buildpacks you rely on.

The Haskell on Heroku buildpack streamlines the process of deploying Haskell applications by automatically installing the full Haskell toolchain, including GHC and Cabal, directly within Heroku's environment. Once the buildpack is set during app creation, every push to the remote repository triggers a fresh build that compiles the Haskell project into a runnable binary. Heroku then launches this binary according to the instructions in a standard Procfile, making the deployment workflow consistent and predictable. This approach removes the need for manual configuration of build tools and dependencies, allowing developers to focus on writing application code rather than managing infrastructure.

Following the tutorial step by step helps newcomers understand the complete deployment pipeline from a local Haskell project to a live web application. Before beginning, users should have a Heroku account, the Heroku CLI installed, and a properly configured Git repository containing a valid cabal file with an executable target. The process starts by logging in through the command line and creating a new Heroku app with the buildpack specified. Each subsequent step guides the user through pushing code and verifying that the application compiles and runs correctly, leading to a fully deployed Haskell app on Heroku's platform.

Next steps

  • Review the Usage notes for stack layout, environment, and configuration.
  • Try a deployable example to see a working project end to end.