This repository offers an introduction to the tagless-final approach, as well as a comparison with alternative approaches - the MTL style, in particular. The introduction is largely based on the following two papers:
- Sound and Efficient Language-Integrated Query - Maintaining the ORDER. By Oleg Kiselyov and Tatsuya Katsushima
- Finally, safely-extensible and efficient language-integrated query. By Kenichi Suzuki, Oleg Kiselyov and Yukiyoshi Kameyama
The material is structured around a number of variations on a theme of Language-Integrated Query. In particular, we will focus on six different ways to perform a query in Scala over a relational database:
- Variation 1. Plain JDBC
- Variation 2. In-memory queries
- Variation 3. Repositories
- Variation 4. MTL-based repositories
- Variation 5. Quoted DSLs: Quill
- Variation 6a. Tagless-final: QUEΛ
- Variation 6b. Tagless-final: From QUEΛ to SQL
Each variation exposes the solution to the problem, and both its advantages and disadvantages. These are mainly framed in the trade-offs between modularity and efficiency conveyed by the use of the different techniques. Tagless-final is presented as one of the techniques to achieve abstraction, without sacrifying efficiency.
Throughout this introduction, we will play with the world database used in the documentation of doobie, a most convenient JDBC wrapper for Scala. You can find instructions here for the set-up of a postgres database server and the installation of the world database. The script common.sc contains several utilities as well as a ready-to-use doobie transactor for issuing SQL queries to the world database.
- Madrid Scala Meetup group, 9/6/20 (slides, video (Spanish))
- Scala Bay meetup, 5/9/20 (slides)