Annotating Deeply Embedded Languages
Summary
A common problem with deeply embedded languages is that there is no strong connection between an embedded program, the abstract syntax tree for that embedded program, and a compiled version of the program. By gathering source location information for embedded expressions using a novel implicit parameter-based approach and annotating the embedded program's AST with this information, it becomes possible to map the embedded program back to the original source code. This new information can be used to improve compiler diagnostics, and to provide better profiling and debugging experiences for the language. In addition, the idea of extending that approach by also annotating the language with instructions for the compiler as a way to allow the programmer to hand optimize parts of a program will be explored. Storing these instructions as annotations on the abstract syntax trees enables new optimization workflows without requiring any changes to the language itself. Finally, an implementation of this annotation system in an existing language is examined, and its consequences on the experience of using the language are evaluated.