Skip to content

aherrmann/example_servant_elm_bazel

Repository files navigation

todo app

A minimal todo app implemented in Haskell using Servant on the backend, and in Elm on the frontend, built with Bazel using rules_haskell and rules_elm.

Requirements

You will need the dependencies of rules_haskell installed on your system to build.

On MacOS you also need to set the following environment variable:

export BAZEL_USE_CPP_ONLY_TOOLCHAIN=1

Instructions

Execute the following command to build and start the app:

$ bazel run //backend

Then browse to http://localhost:8080 to use the app.

Interactive Development

You can use bazel-watcher to continuously rebuild the frontend whenever any of its sources change, like so.

$ ibazel build //frontend

You can use ghcid to continuously reload the backend whenever any of its sources change, like so.

$ ghcid --command="bazel run //backend:backend@ghci" \
    --test=Main.main \
    --setup=":set args --assets bazel-bin/frontend/frontend.tar" \
    --reload=bazel-bin/frontend/frontend.tar

This will load the Haskell code into a GHCi session and run the server in the interpreter. It will reload the session and restart the server whenever any of the Haskell source files or the frontend bundle changes.

Note, if the dependency graph changes, e.g. when you edit a BUILD.bazel file, then you will have to restart ghcid itself.