Skip to search boxSkip to navigationSkip to main content

Practical Reflection and Metaprogramming for Dependent Types

  • David Raymond Christiansen
Research Output:
Theses
PhD thesis

Open access

Publication Information

Output type

Research Output:
Theses
PhD thesis

Original language

English

Qualification

PhD

Publication milestones

  • Published - 2016

Publication status

Published - 2016

Supervisors/Advisors

Award date

07/01/2016

Publisher

IT-Universitetet i København, Denmark

Book series

  • Book series name: ITU-DS
    Series number: 119
    ISSN: 1602-3536
978-87-7949-338-4

Abstract

Embedded domain-specific languages are special-purpose programming languages that are implemented within existing generalpurpose programming languages. Dependent type systems allow strong invariants to be encoded in representations of domain-specific languages, but it can also make it difficult to program in these embedded languages. Interpreters and compilers must always take these invariants into account at each stage, and authors of embedded languages must work hard to relieve users of the burden of proving
these properties.

Idris is a dependently typed functional programming language whose semantics are given by elaboration to a core dependent type theory through a tactic language. This dissertation introduces elaborator reflection, in which the core operators of the elaborator are realized as a type of computations that are executed during the elaboration process of Idris itself, along with a rich API for reflection. Elaborator reflection allows domain-specific languages to be implemented using the same elaboration technology as Idris itself, and it
gives them additional means of interacting with native Idris code. It also allows Idris to be used as its own metalanguage, making it into a programmable programming language and allowing code re-use across all three stages: elaboration, type checking, and execution.

Beyond elaborator reflection, other forms of compile-time reflection have proven useful for embedded languages. This dissertation also describes error reflection, in which Idris code can rewrite DSL error messages before presenting domain-specific messages to users, as well as a means for integrating quasiquotation into a tactic-based elaborator so that high-level syntax can be used for low-level reflected terms.

Access to documents