This is an overview of an example implementation of the RealWorld backend built using the powerful Yesod framework written in Haskell.

This project is essentially a RESTful API to a database and even though Yesod can do much more than that, you still get a lot of nice things that help along the way. For example, Yesod comes with some helper commands for common tasks (e.g. you can add a new handler using yesod add-handler ) and you can start a new project using one of the stack templates. I’ve started this project with stack new yesod-sqlite which scaffolded application with SQLite database connection, whose schema is created from persistent entity file. The scaffolded project is setup with:

development server setup using ghcid with automatic rebuild and fast reloads

hpack for a nicer alternative to the Cabal package format

behaviour specification using hspec

fast and scalable logging using fast-logger for requests and database queries

log functions from monad-logger that includes source code location in the log entries

the fast Warp web server

classy-prelude as an alternative prelude that removes all partial functions

persistent for type-safe database-agnostic data modelling and querying with automatic migrations in development

aeson for fast JSON parsing and encoding

keter deployment system

If you want to learn more about Yesod, you can read the excellent Developing Web Applications with Haskell and Yesod for free. Some other dependencies used in this project are:

esqueleto - type-safe EDSL for SQL queries on persistent backends

forma - parse and validate form input

jwt - JSON Web Token (JWT) decoding and encoding

weeder - to detect dead code

Project structure

Some notes

The handlers are implemented according to the API spec: