Elaborator reflection: extending Idris in Idris

Many programming languages and proof assistants are defined by elaboration from a high-level language with a great deal of implicit information to a highly explicit core language. In many advanced languages, these elaboration facilities contain powerful tools for program construction, but these tools are rarely designed to be repurposed by users. We describe elaborator reflection, a paradigm for metaprogramming in which the elaboration machinery is made directly available to metaprograms, as well as a concrete realization of elaborator reflection in Idris, a functional language with full dependent types. We demonstrate the applicability of Idris’s reflected elaboration framework to a number of realistic problems, we discuss the motivation for the specific features of its design, and we explore the broader meaning of elaborator reflection as it can relate to other languages.

[1]  U. Norell,et al.  Towards a practical programming language based on dependent type theory , 2007 .

[2]  Kenji Takeda,et al.  Themes in information-rich functional programming for internet-scale data sources , 2013, DDFP '13.

[3]  Venanzio Capretta,et al.  Modelling general recursion in type theory , 2005, Mathematical Structures in Computer Science.

[4]  Simon L. Peyton Jones,et al.  OutsideIn(X) Modular type inference with local assumptions , 2011, J. Funct. Program..

[5]  Wouter Swierstra,et al.  Engineering Proof by Reflection in Agda , 2012, IFL.

[6]  Conor McBride,et al.  Inductive Families Need Not Store Their Indices , 2003, TYPES.

[7]  Edwin Brady,et al.  Idris, a general-purpose dependently typed programming language: Design and implementation , 2013, Journal of Functional Programming.

[8]  Matthew Flatt Composable and compilable macros:: you want it when? , 2002, ICFP '02.

[9]  Dominique Devriese,et al.  Typed syntactic meta-programming , 2013, ICFP.

[10]  Viktor Vafeiadis,et al.  Mtac: a monad for typed tactic programming in Coq , 2013, ICFP.

[11]  Peter Morris,et al.  The gentle art of levitation , 2010, ICFP '10.

[12]  David Raymond Christiansen Type-Directed Elaboration of Quasiquotations: A High-Level Syntax for Low-Level Reflection , 2014, IFL.

[13]  David Aspinall,et al.  Proof General: A Generic Tool for Proof Development , 2000, TACAS.

[14]  Eli Barzilay,et al.  Implementing Reflection in Nuprl , 2005 .

[15]  Simon L. Peyton Jones,et al.  Template meta-programming for Haskell , 2002, Haskell '02.

[16]  Eugene Burmako,et al.  Scala macros: let our powers combine!: on how rich syntax and static types work with metaprogramming , 2013, SCALA@ECOOP.

[17]  Jean-Yves Girard,et al.  Typed Lambda Calculi and Applications , 2002, Lecture Notes in Computer Science.

[18]  David Raymond Christiansen,et al.  Dependent type providers , 2013, WGP '13.

[19]  Ulf Norell,et al.  Prototyping Generic Programming in Template Haskell , 2004, MPC.

[20]  Pierre-Yves Strub,et al.  Dependent types and multi-monadic effects in F* , 2016, POPL.

[21]  Conor McBride Turing-Completeness Totally Free , 2015, MPC.

[22]  David Raymond Christiansen,et al.  Practical Reflection and Metaprogramming for Dependent Types , 2016 .

[23]  Peter Dybjer,et al.  A general formulation of simultaneous inductive-recursive definitions in type theory , 2000, Journal of Symbolic Logic.

[24]  Thorsten Altenkirch,et al.  Generic Programming within Dependently Typed Programming , 2002, Generic Programming.

[25]  Andres Löh,et al.  Generic Generic Programming , 2014, PADL.

[26]  Susanne Graf,et al.  Tools and Algorithms for the Construction and Analysis of Systems , 2000 .

[27]  Peter Dybjer,et al.  A Finite Axiomatization of Inductive-Recursive Definitions , 1999, TLCA.

[28]  Peter Dybjer,et al.  Universes for Generic Programs and Proofs in Dependent Type Theory , 2003, Nord. J. Comput..

[29]  David Delahaye,et al.  A Tactic Language for the System Coq , 2000, LPAR.

[30]  Edwin Brady,et al.  Scrapping your inefficient engine: using partial evaluation to improve domain-specific language implementation , 2010, ICFP '10.

[31]  Johan Jeuring,et al.  A generic deriving mechanism for Haskell , 2010, Haskell '10.