Selda: A Haskell SQL Library

The Tutorial of Selda

As Selda uses a lot of fancy type magic to achieve a safe yet flexible programming model, figuring out how to use it from type signatures alone can be hard. While the types keep queries nice and safe, Haskell's type errors can be a bit daunting even under the best circumstances.

This tutorial aims to give the reader a thorough intuition of how Selda works and why, to make those type errors more manageable and to help the reader avoid making them in the first place.

Selda uses GHC's custom type error mechanism to make type errors more helpful, so if you encounter an error that confuses you even after reading this tutorial, please file a bug and we'll see what we can do about it.

This tutorial assumes that the reader is already familiar with relational databases and can write and understand simple SQL queries. It is structured around a series of progressively more advanced Selda examples, which are dissected and discussed in depth, concept by concept.

Get started!