Abstract
We 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 rules. Turnstile critically depends on the idea of linguistic reuse. It exploits a macro system in a novel way to simultaneously type check and rewrite a surface program into a target language. Reusing a macro system also yields modular implementations whose rules may be mixed and matched to create other languages. Combined with typical compiler and runtime reuse, Turnstile produces performant typed embedded languages with little effort.
- The computer language benchmarks game.Google Scholar
- C. Andreae, J. Noble, S. Markstrum, and T. Millstein. A framework for implementing pluggable type systems. In Proceedings of the 21st Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, pages 57–74, 2006. Google Scholar
Digital Library
- P. Bagwell. DSLs - A powerful Scala feature, 2009.Google Scholar
- G. Bracha. Pluggable type systems. In OOPSLA Workshop on Revival of Dynamic Languages, 2004.Google Scholar
- N. G. D. Bruijn. Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. INDAG. MATH, 34:381–392, 1972.Google Scholar
Cross Ref
- E. Burmako. Scala macros: Let our powers combine!: On how rich syntax and static types work with metaprogramming. In Proceedings of the 4th Workshop on Scala, 2013. Google Scholar
Digital Library
- M. Butterick. Pollen: the book is a program, 2013.Google Scholar
- N. Cameron. Sets of scopes macro hygiene in Rust, 2015.Google Scholar
- R. Culpepper and M. Felleisen. Fortifying macros. In Proceeding of the 15th ACM SIGPLAN International Conference on Functional Programming, pages 235–246, 2010. Google Scholar
Digital Library
- T. Disney. Hygienic Macros for JavaScript. PhD thesis, University of California Santa Cruz, 2015.Google Scholar
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. SugarJ: Librarybased syntactic language extensibility. In Proceedings of the ACM SIGPLAN International Conference on Object-oriented Programming Systems Languages and Applications, pages 391–406, 2011. Google Scholar
Digital Library
- M. Felleisen, R. B. Findler, M. Flatt, S. Krishnamurthi, E. Barzilay, J. McCarthy, and S. Tobin-Hochstadt. The Racket Manifesto. In 1st Summit on Advances in Programming Languages (SNAPL 2015), pages 113–128, 2015.Google Scholar
- D. Fisher and O. Shivers. Static analysis for syntax objects. In Proceedings of the 11th ACM SIGPLAN International Conference on Functional Programming, pages 111–121, 2006. Google Scholar
Digital Library
- M. Flatt. Binding as sets of scopes. In Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 705–717, 2016. Google Scholar
Digital Library
- M. Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010- 1, PLT Design Inc., 2010. http://racket-lang.org/tr1/.Google Scholar
- M. Flatt, R. Culpepper, D. Darais, and R. B. Findler. Macros that work together. Journal of Functional Programming, 22(2):181–216, 2012. Google Scholar
Digital Library
- M. Fowler and R. Parsons. Domain-Specific Languages. Addison-Wesley, 2010. Google Scholar
Digital Library
- S. Freeman, T. Mackinnon, N. Pryce, and J. Walnes. Mock roles, not objects. In Companion to the 19th Annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, pages 236–246, 2004. Google Scholar
Digital Library
- M. Gasbichler and M. Sperber. Integrating user-level threads with processes in Scsh. Higher Order Symbol. Comput., 18(3-4):327–354, 2005. Google Scholar
Digital Library
- P. Graham. On Lisp. Prentice Hall, 1993.Google Scholar
- B. Greenman. Trivial: Observably smarter typechecking, 2016.Google Scholar
- D. Herman, L. Wagner, and A. Zakai. asm.js working draft, 2014.Google Scholar
- P. Hudak. Building domain-specific embedded languages. ACM Comput. Surv., 28(4es), 1996. Google Scholar
Digital Library
- P. Hudak. Modular domain specific languages and tools. In Proceedings of the 5th International Conference on Software Reuse, pages 134–142, 1998. Google Scholar
Digital Library
- S. Kamin and D. Hyatt. A special-purpose language for picturedrawing. In Proceedings of the USENIX Conference on Domain-Specific Languages, pages 297–310, 1997. Google Scholar
Digital Library
- G. Kossakowski, N. Amin, T. Rompf, and M. Odersky. JavaScript as an embedded DSL. In European Conference on Object-Oriented Programming, pages 409–434. Springer Berlin Heidelberg, 2012. Google Scholar
Digital Library
- S. Krishnamurthi. Linguistic Reuse. PhD thesis, Rice University, 2001. Google Scholar
Digital Library
- B. S. Lerner, J. G. Politz, A. Guha, and S. Krishnamurthi. Tejas: retrofitting type systems for JavaScript. In Proceedings of the 9th Symposium on Dynamic Languages, pages 1–16, 2013. Google Scholar
Digital Library
- M. Y. Levin and B. C. Pierce. TinkerType: A language for playing with formal systems. J. Funct. Program., 13(2):295–316, 2003. Google Scholar
Digital Library
- F. Lorenzen and S. Erdweg. Sound type-dependent syntactic language extension. In Proceedings of the 43rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 204–216, 2016. Google Scholar
Digital Library
- Y. Minsky, A. Madhavapeddy, and J. Hickey. Real World OCaml. O’Reilly Media, 2013.Google Scholar
- S. Moore, C. Dimoulas, D. King, and S. Chong. Shill: A secure shell scripting language. In Proceedings of the 11th USENIX Conference on Operating Systems Design and Implementation, pages 183–199, 2014. Google Scholar
Digital Library
- F. Nielson and H. R. Nielson. Correct System Design: Recent Insights and Advances, chapter Type and Effect Systems, pages 114– 136. Springer Berlin Heidelberg, 1999. Google Scholar
Digital Library
- C. Okasaki. Purely Functional Data Structures. Cambridge University Press, 1999. Google Scholar
Digital Library
- C. Omar and J. Aldrich. Programmable semantic fragments: The design and implementation of typy. In Proceedings of the 15th International Conference on Generative Programming: Concepts & Experience, page (to appear), 2016. Google Scholar
Digital Library
- C. Omar, D. Kurilova, L. Nistor, B. Chung, A. Potanin, and J. Aldrich. Safely composable type-specific languages. In Proceedings of the European Conference on Object-Oriented Programming, pages 105– 130. 2014. Google Scholar
Digital Library
- M. M. Papi, M. Ali, T. L. Correa Jr., J. H. Perkins, and M. D. Ernst. Practical pluggable types for Java. In Proceedings of the 2008 International Symposium on Software Testing and Analysis, pages 201–212, 2008. Google Scholar
Digital Library
- B. C. Pierce. Types and Programming Languages. MIT Press, 2002. Google Scholar
Digital Library
- B. C. Pierce and D. N. Turner. Local type inference. In Proceedings of the 25th ACM SIGPLAN–SIGACT Symposium on Principles of Programming Languages, pages 252–265, 1998. Google Scholar
Digital Library
- J. G. Siek, M. M. Vitousek, M. Cimini, and J. T. Boyland. Refined criteria for gradual typing. In 1st Summit on Advances in Programming Languages, pages 274–293, 2015.Google Scholar
- T. S. Strickland, B. M. Ren, and J. S. Foster. Contracts for domainspecific languages in Ruby. In Proceedings of the 10th ACM Symposium on Dynamic Languages, pages 23–34, 2014. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In Proceedings of the 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 395– 406, 2008. Google Scholar
Digital Library
- S. Tobin-Hochstadt, V. St-Amour, R. Culpepper, M. Flatt, and M. Felleisen. Languages as libraries. In Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 132–141, 2011. Google Scholar
Digital Library
- E. Torlak and R. Bodik. A lightweight symbolic virtual machine for solver-aided host languages. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 530–541, 2014. Google Scholar
Digital Library
- B. Valiron, N. J. Ross, P. Selinger, D. S. Alexander, and J. M. Smith. Programming the quantum future. Communications of the ACM, 58 (8):52–61, 2015. Google Scholar
Digital Library
- T. Veldhuizen. Using C++ template metaprograms. C++ Report, 7 (4):36–43, May 1995.Google Scholar
- P. Wadler and S. Blott. How to make ad-hoc polymorphism less adhoc. In Proceedings of the 16th ACM Symposium on Principles of Programming Languages, pages 60–76, 1989. Google Scholar
Digital Library
- J. Yallop and L. White. Modular macros. In Proceedings of the OCaml Users and Developers Workshop, 2015.Google Scholar
Index Terms
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 ...
Macros for domain-specific languages
Macros provide a powerful means of extending languages. They have proven useful in both general-purpose and domain-specific programming contexts. This paper presents an architecture for implementing macro-extensible DSLs on top of macro-extensible host ...
Dependent type systems as macros
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 ...







Comments