A cookiecutter template for (almost) production-ready Servant servers.
My goal is to reduce friction for people starting working on Haskell REST API servers by putting together a few best practices in a way that's not intrusive or prescriptive.
$ pip install --user cookiecutter $ cookiecutter gh:jml/servant-template
Once the template is created, you can build things with
stack or use the
Your API definition goes in the
YourApp.API module and the application logic in the
Things you get with this template:
- Logging using logging-effect
- Prometheus instrumentation using prometheus-client
- Command-line parsing with optparse-applicative
- Tests with servant-quickcheck
- Make target to build a Docker image tagged with the Git revision ID.
This cookiecutter project makes a few opinionated decisions:
- GHC 8.0 only
- Built with Stack
package.yaml(from hpack) to configure dependencies etc.
- Protolude as the Prelude
- The root page of the service has a simple HTML page intended for use by developers
- There is only one executable: the binary that launches the server
- The hackage name is the repo name is the project name is the executable name
- Uses CircleCI as its default CI tool
- Enforces hindent-formatted code in CI
- The code that defines the API is in a separate library to the code that implements it
Many of these opinions are lightly held. If this template would be more useful to you with some of them changed, please file an issue or submit a PR.
Note that the Cabal file is not checked in to this cookiecutter template.
You can build a Docker image with