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!Chapters
- An Example, Explained. Covers the definition and creation of tables, inserting values, and performing simple queries.
- Destructive Operations. Covers deletes, updates, and more advanced flavours of insert.
- Advanced Queries. Covers ad hoc creation of rows from within queries, and other misc. neat query tricks.
- Joins and Aggregates (TBD). Covers the various types of joins and aggregate queries supported by Selda.
- Constraints and Indexes (TBD). Covers more advanced schema definitions, including foreign keys, indexes, and other constraints.
- Migrations and Prepared Statements (TBD). Covers how to migrate database tables from one schema to another, and how to improve performance through prepared statements.