This page collects the course materials, in the form of the extensively commented OCaml code.
It was recently discovered how to transform, simplify, and generally, optimize DSLs embedded in this style. The optimizations are reusable, modular, composable, and type- and scope-preserving by construction.
In this incarnation of the course we expound the denotational/algebraic perspective on DSL optimization, using as the running example a simple hardware description DSL.
By the end of the tutorial, the participants will:
The presented framework has been used for real-life projects, such as the compositional and extensive language-integrated query. It is the first such system able to optimize ORDER BY queries.
The tutorial is meant to be interactive: interacting with the audience and with the OCaml interpreter, working through problems with active audience participation. The following is the complete OCaml source code that was presented and interacted with during the lectures. It has been amended to reflect questions and comments of the participants. The code is extensively commented: the comments are the lecture notes. No libraries or packages beyond the standard library are needed to run the code: the most basic OCaml installation should suffice.
algebra.ml
, for contrast and to highlight
different aspects of tagless-final as algebras
The tutorial has numerous quizzes: search for ``QUIZ'' in the source
code files. Other good exercises are: selective inlining (combine only
those circuits when doing so will not lead to duplication);
writing the optimizations of the sort AND x x -> x
;
earnest Boolean simplification; converting to DNF;
handling sharing.