Practical Reflection and Metaprogramming for Dependent Types

David Raymond Christiansen

    Research output: Book / Anthology / Report / Ph.D. thesisPh.D. thesis

    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.
    Original languageEnglish
    PublisherIT-Universitetet i København
    Number of pages182
    ISBN (Print)978-87-7949-338-4
    Publication statusPublished - 2016
    SeriesITU-DS
    Number119
    ISSN1602-3536

    Fingerprint

    Dive into the research topics of 'Practical Reflection and Metaprogramming for Dependent Types'. Together they form a unique fingerprint.

    Cite this