Your Program Is a Language
summary
Claim: programs are just languages and the best embedded DSL style is tagless final. Demonstrations use Scala 3 features like opaque types and extension methods, plus Cats/free monad examples and an in-memory CRUD library wired to http4s and circe. Trade-offs shown: ADT/free gives easy serialization but extra runtime allocation and the expression problem; tagless final avoids that and supports multiple interpreters. A toy calculator and a running CRUD server prove the approaches compile and respond as expected.
AI-written summary · about
chapters (21)
- 0:00Introduction to DSLs
- 1:49What are DSLs?
- 4:17Cohesion and coupling in DSLs
- 6:25Library code vs DSLs
- 8:10DSL styles and implementation
- 11:18Embedded vs external DSLs
- 12:40Tagless final style
- 14:46Opaque types for DSLs
- 15:49DSL as data structure
- 18:59Free monad for DSLs
- 20:45Tagless final approach
- 23:09Advantages of tagless final
- 25:41The expression problem
- 29:57Extending DSLs with tagless
- 30:38Calculator DSL example
- 32:23Tagless calculator demo
- 35:12CRUD DSL library
- 40:04CRUD server demo
- 42:30DSL design techniques
- 44:58Financial account DSL
- 45:19Key takeaways and resources
