Free vs Tagless Final: What, Why, When?
summary
Compares concrete encodings by building a small Scala DSL with integer and string literals, addition, concatenation and string→int conversion, then implements evaluators and a pretty-printer to show what works. Shows initial/ADT, GADT-typed ADT to prevent invalid programs, datatypes à la carte and free monad as initial variants, and tagless final as typeclass combinators; demonstrates adding if, composing extensions, an inlining optimizer (harder in final), round‑trip translations, and recommends initial for inspection-heavy work and final for extensibility and performance.
AI-written summary · about
chapters (5)
- 0:00Start
- 0:24Free vs Tagless
- 2:08Initial vs Final vs Tagged
- 15:09Case Study: Adding a pretty printer
- 46:08Comparison
related talks
21mFinally Tagless DSLs and MTL
14mNominal Semantics for First-class Automatic Differentiation
40mThe Origins of Free
53mThe Origins of Free
52mBake Real-life Apps with a Handful of Free, Coproducts & Types
52mZero Cost Abstractions Eliminating Runtime Overhead in Scala
01h 20mA Practical Introduction to Haskell GADTs
54mOpaque Types To Infinity
