Domain-specific languages (DSLs) are essential components of effective libraries and frameworks. This course takes advantage of functional programming techniques in the design of DSLs. In particular, it shows how to exploit GADTs and type classes in the specification of the syntax, type system and semantics of embedded DSLs in Scala. Several examples of untyped and typed DSLs will be described, but the course will focus on the design of one or two DSLs identified beforehand. Accordingly, the course is structured into three major modules aimed at designing and implementing the different concerns in the design of those DSLs: their deep and surface syntax, their type system, and their semantics, both standard (suitable for unit and property-based testing) and non-standard (suitable for production-purposes).
AUDIENCE
- The course assumes familiarity with Scala and basic functional programming techniques
- Senior programmers in charge of library and framework development, or complex, large-scale applications
COURSE OUTLINE (16 hours)
MODULE 1. Syntax of DSLs
- Deep syntax
- Surface syntax
- DSL development (I)
MODULE 2. Type systems of DSLs
- Typed vs. untyped DSLs
- DSL development (II)
MODULE 3. Semantics: standard and non-standard
- Standard semantics (testing)
- Non-standard semantics (production)
- DSL development (III)
MODULE 3. Advanced topics in DSL design and implementation
- Tagless-final vs. Quoted DSLs
- Scala 3 macros and multi-staging programming