Abstract
We present Turnstile+, a high-level, macros-based metaDSL for building dependently typed languages.
With it, programmers may rapidly prototype and iterate on the design of new dependently typed features and extensions.
Or they may create entirely new DSLs whose dependent type ``power'' is tailored to a specific domain.
Our framework's support of language-oriented programming also makes it suitable for experimenting with systems of interacting components, e.g., a proof assistant and its companion DSLs.
This paper explains the implementation details of Turnstile+, as well as how it may be used to create a wide-variety of dependently typed languages, from a lightweight one with indexed types, to a full spectrum proof assistant, complete with a tactic system and extensions for features like sized types and SMT interaction.
Supplemental Material
- 2017. RFC: The pi type trilogy. https://github.com/rust-lang/rfcs/issues/1930Google Scholar
- Andreas Abel. 2010. MiniAgda: Integrating Sized and Dependent Types. In PAR (EPTCS), Ana Bove, Ekaterina Komendantskaya, and Milad Niqui (Eds.), Vol. 43. 14–28. http://dblp.uni-trier.de/db/series/eptcs/eptcs43.html#abs-1012-4896Google Scholar
- Andreas Abel. 2012. Type-Based Termination, Inflationary Fixed-Points, and Mixed Inductive-Coinductive Types. In Proceedings 8th Workshop on Fixed Points in Computer Science, FICS 2012, Tallinn, Estonia, 24th March 2012. 1–11. Google Scholar
Cross Ref
- Thorsten Altenkirch, Nils Anders Danielsson, Andres Löh, and Nicolas Oury. 2010. ΠΣ: Dependent Types Without the Sugar. In Proceedings of the 10th International Conference on Functional and Logic Programming (FLOPS’10). 40–55.Google Scholar
Digital Library
- Nada Amin, Tiark Rompf, and Martin Odersky. 2014. Foundations of Path-dependent Types. In Proceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications (OOPSLA ’14). ACM, New York, NY, USA, 233–249. Google Scholar
Digital Library
- Abhishek Anand, Simon Boulier, Cyril Cohen, Matthieu Sozeau, and Nicolas Tabareau. 2018. Towards Certified MetaProgramming with Typed Template-Coq. (2018). www.irif.fr/~sozeau/research/publications/drafts/Towards_Certified_ Meta-Programming_with_Typed_Template-Coq.pdfGoogle Scholar
- Leif Andersen, Stephen Chang, and Matthias Felleisen. 2017. Super 8 Languages for Making Movies (Functional Pearl). Proc. ACM Program. Lang. 1, ICFP, Article 30 (Aug. 2017), 29 pages. Google Scholar
Digital Library
- Lennart Augustsson. 2007. Simpler, Easier! http://augustss.blogspot.ru/2007/10/simpler-easier-in-recent-paper-simply.htmlGoogle Scholar
- Andrej Bauer. 2012. How to Implement Dependent Type Theory. http://math.andrej.com/2012/11/08/how-to-implementdependent-type-theory-i/Google Scholar
- Jasmin C. Blanchette, Cezary Kaliszyk, Lawrence C. Paulson, and Josef Urban. 2016. Hammering towards QED. J. Formaliz. Reason. 9, 1 (2016), 101–148.Google Scholar
- Edwin Brady and Kevin Hammond. 2006. Dependently Typed MetaProgramming. In 7th Symposium on Trends in Functional Programming.Google Scholar
- Edwin C. Brady. 2005. Practical Implementation of a Dependently Typed Functional Programming Language. Ph.D. Dissertation. University of Durham.Google Scholar
- Stephen Chang, Alex Knauth, and Ben Greenman. 2017. Type Systems As Macros. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages. 694–705.Google Scholar
Digital Library
- David Christiansen and Edwin Brady. 2016. Elaborator Reflection: Extending Idris in Idris. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016). ACM, New York, NY, USA, 284–297. Google Scholar
Digital Library
- Jesper Cockx, Dominique Devriese, and Frank Piessens. 2014. Pattern Matching Without K. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). ACM, New York, NY, USA, 257–268. Google Scholar
Digital Library
- Thierry Coquand. 1992. Pattern Matching with Dependent Types. In Proceedings of the Workshop on Types for Proofs and Programs. 71–83.Google Scholar
- Thierry Coquand and Gérard P. Huet. 1988. The Calculus of Constructions. Inf. Comput. 76, 2/3 (1988), 95–120. Google Scholar
Digital Library
- Vincent Cremet, François Garillot, Sergueï Lenglet, and Martin Odersky. 2006. A Core Calculus for Scala Type Checking. In Proceedings of the 31st International Conference on Mathematical Foundations of Computer Science (MFCS’06). SpringerVerlag, Berlin, Heidelberg, 1–23. Google Scholar
Digital Library
- N.G. de Bruijn. 1991. Telescopic Mappings in Typed Lambda-Calculus. Information and Computation 91, 2 (1991), 189–204.Google Scholar
Digital Library
- David Delahaye. 2000. A Tactic Language for the System Coq. In Proceedings of the 7th International Conference on Logic for Programming and Automated Reasoning (LPAR’00). Springer-Verlag, Berlin, Heidelberg, 85–95. http://dl.acm.org/citation. cfm?id=1765236.1765246Google Scholar
Cross Ref
- Dominique Devriese and Frank Piessens. 2013. Typed Syntactic Meta-programming. In of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP 2013). 73–86.Google Scholar
- Peter Dybjer. 1994. Inductive families. Formal Aspects of Computing 6, 4 (01 Jul 1994), 440–465.Google Scholar
- R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. 1992. Syntactic Abstraction in Scheme. Lisp Symb. Comput. 5, 4 (Dec. 1992), 295–326. Google Scholar
Digital Library
- Gabriel Ebner, Sebastian Ullrich, Jared Roesch, Jeremy Avigad, and Leonardo de Moura. 2017. A metaprogramming framework for formal verification. Proceedings of the ACM on Programming Languages (PACMPL) 1, ICFP (2017), 34:1–34:29. Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi, Eli Barzilay, Jay McCarthy, and Sam Tobin-Hochstadt. 2015. The Racket Manifesto. In 1st Summit on Advances in Programming Languages (SNAPL 2015). 113–128.Google Scholar
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi, Eli Barzilay, Jay McCarthy, and Sam Tobin-Hochstadt. 2018. A Programmable Programming Language. Commun. ACM 61, 3 (Feb. 2018), 62–71. Google Scholar
Digital Library
- Matthew Flatt. 2002. Composable and Compilable Macros: You Want It when?. In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP ’02). ACM, New York, NY, USA, 72–83. Google Scholar
Digital Library
- Matthew Flatt. 2016. Binding As Sets of Scopes. In Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 705–717.Google Scholar
Digital Library
- Matthew Flatt, Ryan Culpepper, David Darais, and Robert Bruce Findler. 2012. Macros That Work Together: Compiletime Bindings, Partial Expansion, and Definition Contexts. 22, 2 (March 2012), 181–216. Google Scholar
Digital Library
- Eduardo Giménez. 1995. Codifying Guarded Definitions with Recursive Schemes. In International Workshop on Types for Proofs and Programs (TYPES). Google Scholar
Cross Ref
- Healfdene Goguen, Conor McBride, and James McKinna. 2006. Eliminating Dependent Pattern Matching. In Algebra, Meaning, and Computation: Essays dedicated to Joseph A. Goguen on the Occasion of His 65th Birthday, Kokichi Futatsugi, Jean-Pierre Jouannaud, and José Meseguer (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 521–540. Google Scholar
Cross Ref
- Georges Gonthier and Assia Mahboubi. 2010. An introduction to small scale reflection in Coq. Journal of Formalized Reasoning 3, 2 (2010), 95–152. https://hal.inria.fr/inria-00515548Google Scholar
- Georges Gonthier, Beta Ziliani, Aleksandar Nanevski, and Derek Dreyer. 2011. How to Make Ad Hoc Proof Automation Less Ad Hoc. In Proceedings of the 16th ACM SIGPLAN International Conference on Functional Programming (ICFP ’11). ACM, New York, NY, USA, 163–175. Google Scholar
Digital Library
- John Hughes, Lars Pareto, and Amr Sabry. 1996. Proving the Correctness of Reactive Systems Using Sized Types. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’96). ACM, New York, NY, USA, 410–423. Google Scholar
Digital Library
- Joomy Korkut and David Christiansen. 2018. Extensible Type-Directed Editing. In Proceedings of the Workshop on Type-Driven Development.Google Scholar
Digital Library
- Robbert Krebbers, Amin Timany, and Lars Birkedal. 2017. Interactive Proofs in Higher-order Concurrent Separation Logic. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA, 205–217. Google Scholar
Digital Library
- Andres Löh, Conor McBride, and Wouter Swierstra. 2010. A Tutorial Implementation of a Dependently Typed Lambda Calculus. Fundam. Inform. 102, 2 (2010), 177–207.Google Scholar
Digital Library
- Gregory Malecha and Jesper Bengtson. 2016. Programming Languages and Systems: 25th European Symposium on Programming, ESOP 2016, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2016, Eindhoven, The Netherlands, April 2-8, 2016, Proceedings. Springer Berlin Heidelberg, Berlin, Heidelberg, Chapter Extensible and Efficient Automation Through Reflective Tactics, 532–559. Google Scholar
Cross Ref
- Alberto Martelli and Ugo Montanari. 1982. An Efficient Unification Algorithm. ACM Trans. Program. Lang. Syst. 4, 2 (April 1982), 258–282. Google Scholar
Digital Library
- Per Martin-Löf. 1975. An intuitionistic theory of types: Predicative part. Studies in Logic and the Foundations of Mathematics 80 (1975), 73–118.Google Scholar
Cross Ref
- Conor McBride. 2000. Dependently Typed Functional Programs and Their Proofs. Ph.D. Dissertation. University of Edinburgh, UK. http://hdl.handle.net/1842/374Google Scholar
- Bengt Nordström, Kent Petersson, and Jan M. Smith. 1990. Programming in Martin-Löf’s Type Theory: An Introduction. Clarendon Press, New York, NY, USA.Google Scholar
Digital Library
- Ulf Norell. 2007. Towards a Practical Programming Language Based on Dependent Type Theory. Ph.D. Dissertation. Chalmers University of Technology. http://www.cse.chalmers.se/~ulfn/papers/thesis.pdfGoogle Scholar
- Brigitte Pientka. 2008. A Type-theoretic Foundation for Programming with Higher-order Abstract Syntax and Firstclass Substitutions. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). 371–382.Google Scholar
Digital Library
- Benjamin C. Pierce, Arthur Azevedo de Amorim, Chris Casinghino, Marco Gaboardi, Michael Greenberg, Cˇ atˇ alin Hriţcu, Vilhelm Sjöberg, and Brent Yorgey. 2018. Logical Foundations. Electronic textbook.Google Scholar
- Benjamin C. Pierce and David N. Turner. 1998. Local Type Inference. In Proceedings of the 25th ACM SIGPLAN–SIGACT Symposium on Principles of Programming Languages. 252–265.Google Scholar
- Justin Pombrio and Shriram Krishnamurthi. 2015. Hygienic Resugaring of Compositional Desugaring. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming (ICFP 2015). ACM, New York, NY, USA, 75–87. Google Scholar
Digital Library
- Peter Sewell, Francesco Zappa Nardelli, Scott Owens, Gilles Peskine, Thomas Ridge, Susmit Sarkar, and Rok Strniša. 2007. Ott: Effective Tool Support for the Working Semanticist. In of the 12th ACM SIGPLAN International Conference on Functional Programming (ICFP 2007). ACM, New York, NY, USA, 1–12. Google Scholar
Digital Library
- Antonis Stampoulis and Zhong Shao. 2010. VeriML: Typed Computation of Logical Terms Inside a Language with Effects. In of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP 2010). 333–344.Google Scholar
Digital Library
- Emina Torlak and Rastislav Bodik. 2014. A Lightweight Symbolic Virtual Machine for Solver-aided Host Languages. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation. 530–541.Google Scholar
Digital Library
- Stephanie Weirich. 2014. Pi Forall: notes from OPLSS. https://github.com/sweirich/pi-forallGoogle Scholar
- Stephanie Weirich, Antoine Voizard, Pedro Henrique Avezedo de Amorim, and Richard A. Eisenberg. 2017. A Specification for Dependent Types in Haskell. Proceedings of the ACM on Programming Languages (PACMPL) 1, ICFP (Aug. 2017). Google Scholar
Digital Library
- Hongwei Xi. 2007. Dependent ML An approach to practical programming with dependent types. Journal of Functional Programming 17, 2 (2007), 215–286. Google Scholar
Digital Library
- Brent A. Yorgey, Stephanie Weirich, Julien Cretin, Simon L. Peyton Jones, Dimitrios Vytiniotis, and José Pedro Magalhães. 2012. Giving Haskell a promotion. In Types in Language Design and Implementation (TLDI). Google Scholar
Digital Library
- Beta Ziliani, Derek Dreyer, Neelakantan R Krishnaswami, Aleksandar Nanevski, and Viktor Vafeiadis. 2013. Mtac: A Monad for Typed Tactic Programming in Coq. In Proceedings of the 18th ACM SIGPLAN International Conference on Functional Programming (ICFP 2013). ACM, New York, NY, USA, 87–100. Google Scholar
Digital Library
- Jean Karim Zinzindohoué, Karthikeyan Bhargavan, Jonathan Protzenko, and Benjamin Beurdouche. 2017. HACL*: A Verified Modern Cryptographic Library. In Conference on Computer and Communications Security, (CCS). Google Scholar
Digital Library
Index Terms
Dependent type systems as macros
Recommendations
Type systems as macros
POPL '17: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming LanguagesWe present Turnstile, a metalanguage for creating typed embedded languages. To implement the type system, programmers write type checking rules resembling traditional judgment syntax. To implement the semantics, they incorporate elaborations into these ...
Type systems as macros
POPL '17We present Turnstile, a metalanguage for creating typed embedded languages. To implement the type system, programmers write type checking rules resembling traditional judgment syntax. To implement the semantics, they incorporate elaborations into these ...
Cayenne—a language with dependent types
Cayenne is a Haskell-like language. The main difference between Haskell and Cayenne is that Cayenne has dependent types, i.e., the result type of a function may depend on the argument value, and types of record components (which can be types or values) ...






Comments