Typed syntactic meta-programming

We present a novel set of meta-programming primitives for use in a dependently-typed functional language. The types of our meta-programs provide strong and precise guarantees about their termination, correctness and completeness. Our system supports type-safe construction and analysis of terms, types and typing contexts. Unlike alternative approaches, they are written in the same style as normal programs and use the language's standard functional computational model. We formalise the new meta-programming primitives, implement them as an extension of Agda, and provide evidence of usefulness by means of two compelling applications in the fields of datatype-generic programming and proof tactics.

[1]  Samuel Boutin,et al.  Using Reflection to Build Efficient and Certified Decision Procedures , 1997, TACS.

[2]  Zhong Shao,et al.  Static and user-extensible proof checking , 2012, POPL '12.

[3]  Derek Dreyer,et al.  How to make ad hoc proof automation less ad hoc , 2011, ICFP '11.

[4]  Emir Pasalic,et al.  Meta-programming with Typed Object-Language Representations , 2004, GPCE.

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

[6]  Ulf Norell,et al.  Parsing Mixfix Operators , 2008, IFL.

[7]  Amr Sabry,et al.  Backtracking, interleaving, and terminating monad transformers: (functional pearl) , 2005, ICFP '05.

[8]  Thierry Coupaye,et al.  ASM: a code manipulation tool to implement adaptable systems , 2002 .

[9]  Peter Thiemann,et al.  Mnemonics: type-safe bytecode generation at run time , 2010, PEPM '10.

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

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

[12]  Edwin Brady,et al.  A verified staged interpreter is a verified compiler , 2006, GPCE '06.

[13]  Conor McBride,et al.  Eliminating Dependent Pattern Matching , 2006, Essays Dedicated to Joseph A. Goguen.

[14]  Conor McBride,et al.  Outrageous but meaningful coincidences: dependent type-safe syntax and evaluation , 2010, WGP '10.

[15]  G. Bezhanishvili GÖDEL’S INCOMPLETENESS THEOREMS , 2019, Infinity and the Mind.

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

[17]  Simon L. Peyton Jones,et al.  Scrap your boilerplate: a practical design pattern for generic programming , 2003, TLDI '03.

[18]  James Chapman,et al.  Type Theory Should Eat Itself , 2008, LFMTP@LICS.

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

[20]  KiselyovOleg,et al.  Backtracking, interleaving, and terminating monad transformers , 2005 .

[21]  Zhong Shao,et al.  VeriML: typed computation of logical terms inside a language with effects , 2010, ICFP '10.

[22]  Emir Pasalic,et al.  Meta-programming With Built-in Type Equality , 2008, Electron. Notes Theor. Comput. Sci..

[23]  Carsten Schürmann,et al.  Practical Programming with Higher-Order Encodings and Dependent Types , 2008, ESOP.

[24]  Nils Anders Danielsson Operational semantics using the partiality monad , 2012, ICFP '12.

[25]  Per Martin-Löf,et al.  An intuitionistic theory of types , 1972 .

[26]  Walid Taha,et al.  MetaML and multi-stage programming with explicit annotations , 2000, Theor. Comput. Sci..

[27]  Chiyan Chen,et al.  Meta-programming through typeful code representation , 2003, ICFP '03.

[28]  K. Gödel Über formal unentscheidbare Sätze der Principia Mathematica und verwandter Systeme I , 1931 .

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

[30]  Russell W. Quong,et al.  ANTLR: A predicated‐LL(k) parser generator , 1995, Softw. Pract. Exp..

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

[32]  K. Gödel Über formal unentscheidbare Sätze der Principia Mathematica und verwandter Systeme I , 1931 .

[33]  Andreas Abel Irrelevance in Type Theory with a Heterogeneous Equality Judgement , 2011, FoSSaCS.

[34]  Brigitte Pientka,et al.  Programming with proofs and explicit contexts , 2008, PPDP '08.

[35]  Simon Marlow,et al.  Haskell 2010 Language Report , 2010 .

[36]  Johan Jeuring,et al.  Generic programming with fixed points for mutually recursive datatypes , 2009, ICFP.

[37]  Antonius J. C. Hurkens A Simplification of Girard's Paradox , 1995, TLCA.

[38]  Adam Chlipala Parametric higher-order abstract syntax for mechanized semantics , 2008, ICFP.

[39]  David Abrahams,et al.  C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond (C++ In-Depth Series) , 2004 .

[40]  Adam Chlipala,et al.  Ur: statically-typed metaprogramming with type-level record computation , 2010, PLDI '10.

[41]  Jan Vitek,et al.  The Eval That Men Do - A Large-Scale Study of the Use of Eval in JavaScript Applications , 2011, ECOOP.

[42]  Nils Anders Danielsson A Formalisation of a Dependently Typed Language as an Inductive-Recursive Family , 2006, TYPES.

[43]  Ralf Hinze,et al.  Implementation and Application of Functional Languages , 2012, Lecture Notes in Computer Science.

[44]  Peter Dybjer,et al.  Inductive families , 2005, Formal Aspects of Computing.

[45]  Sam Tobin-Hochstadt,et al.  Languages as libraries , 2011, PLDI '11.

[46]  XiHongwei,et al.  Meta-programming through typeful code representation , 2005 .

[47]  J. Gregory Morrisett,et al.  Nikola: embedding compiled GPU functions in Haskell , 2010, Haskell '10.

[48]  Raymond M. Smullyan,et al.  Godel's Incompleteness Theorems , 1992 .

[49]  Walid Taha,et al.  Concoqtion: indexed types now! , 2007, PEPM '07.

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

[51]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.