Abstract
Language extensions introduce high-level programming constructs that protect programmers from low-level details and repetitive tasks. For such an abstraction barrier to be sustainable, it is important that no errors are reported in terms of generated code. A typical strategy is to check the original user code prior to translation into a low-level encoding, applying the assumption that the translation does not introduce new errors. Unfortunately, such assumption is untenable in general, but in particular in the context of extensible programming languages, such as Racket or SugarJ, that allow regular programmers to define language extensions.
In this paper, we present a formalism for building and automatically verifying the type-soundness of syntactic language extensions. To build a type-sound language extension with our formalism, a developer declares an extended syntax, type rules for the extended syntax, and translation rules into the (possibly further extended) base language. Our formalism then validates that the user-defined type rules are sufficient to guarantee that the code generated by the translation rules cannot contain any type errors. This effectively ensures that an initial type check prior to translation precludes type errors in generated code. We have implemented a core system in PLT Redex and we have developed a syntactically extensible variant of System Fw that we extend with let notation, monadic do blocks, and algebraic data types. Our formalism verifies the soundness of each extension automatically.
- G. Bracha. Pluggable type systems. In OOPSLA Workshop on Revival of Dynamic Languages, 2004. Available at http://bracha.org/pluggableTypesPosition.pdf, accessed at Mar. 26 2013.Google Scholar
- M. Bravenboer, A. v. Dam, K. Olmos, and E. Visser. Program transformation with scoped dynamic rewrite rules. Fundamenta Informaticae, 69(1-2):123--178, 2006. Google Scholar
Digital Library
- K. Crary and S. Weirich. Flexible type analysis. In Proceedings of International Conference on Functional Programming (ICFP), pages 233--248. ACM, 1999. Google Scholar
Digital Library
- D. de Rauglaudre. Camlp4 reference manual. http://caml.inria.fr/pub/docs/manual-camlp4/index.html, 2003. accessed Mar. 26 2013.Google Scholar
- S. Erdweg. Extensible Languages for Flexible and Principled Domain Abstraction. PhD thesis, Philipps-Universiät Marburg, 2013.Google Scholar
- S. Erdweg, P. G. Giarrusso, and T. Rendel. Language composition untangled. In Proceedings of Workshop on Language Descriptions, Tools and Applications (LDTA), pages 7:1--7:8. ACM, 2012. Google Scholar
Digital Library
- S. Erdweg, L. C. L. Kats, T. Rendel, C. Kästner, K. Ostermann, and E. Visser. Growing a language environment with editor libraries. In Proceedings of Conference on Generative Programming and Component Engineering (GPCE), pages 167--176. ACM, 2011. Google Scholar
Digital Library
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. SugarJ: Librarybased syntactic language extensibility. In Proceedings of Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pages 391--406. ACM, 2011. Google Scholar
Digital Library
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. Layout-sensitive generalized parsing. In Proceedings of Conference on Software Language Engineering (SLE), volume 7745 of LNCS, pages 244--263. Springer, 2012.Google Scholar
- S. Erdweg, F. Rieger, T. Rendel, and K. Ostermann. Layout-sensitive language extensibility with SugarHaskell. In Proceedings of Haskell Symposium, pages 149--160. ACM, 2012. Google Scholar
Digital Library
- M. Felleisen, R. B. Findler, and M. Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google Scholar
Digital Library
- D. Fisher and O. Shivers. Static analysis for syntax objects. In Proceedings of International Conference on Functional Programming (ICFP), pages 111--121. ACM, 2006. Google Scholar
Digital Library
- D. Fisher and O. Shivers. Building language towers with Ziggurat. Functional Programming, 18(5-6):707--780, 2008. Google Scholar
Digital Library
- S. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In Proceedings of International Conference on Functional Programming (ICFP), pages 203--217. ACM, 2001. Google Scholar
Digital Library
- B. Heeren, J. Hage, and S. D. Swierstra. Scripting the type inference process. In Proceedings of International Conference on Functional Programming (ICFP), pages 3--13. ACM, 2003. Google Scholar
Digital Library
- D. Herman. A Theory of Typed Hygienic Macros. PhD thesis, Northeastern University, Boston, Massachusetts, 2012. Google Scholar
Digital Library
- J. Los and R. Suszko. Remarks on sentential logics. Indagationes Mathematicae, 20:177--183, 1958.Google Scholar
Cross Ref
- G. Mainland. Explicitly heterogeneous metaprogramming with Meta-Haskell. In Proceedings of International Conference on Functional Programming (ICFP), pages 311--322. ACM, 2012. Google Scholar
Digital Library
- S. Markstrum, D. Marino, M. Esquivel, T. Millstein, C. Andreae, and J. Noble. JavaCOP: Declarative pluggable types for Java. Transactions on Programming Languages and Systems (TOPLAS), 32(2):4:1--4:37, 2010. Google Scholar
Digital Library
- E. Moggi. Notions of computation and monads. Information and Computation, 93(1):55--92, 1991. 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 International Symposium on Software Testing and Analysis (ISSTA), pages 201--212. ACM, 2008. Google Scholar
Digital Library
- B. C. Pierce. Types and programming languages. MIT press, 2002. Google Scholar
Digital Library
- M. Roberson, M. Harries, P. T. Darga, and C. Boyapati. Efficient software model checking of soundness of type systems. In Proceedings of Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), pages 493--504. ACM, 2008. Google Scholar
Digital Library
- A. Schwerdfeger and E. Van Wyk. Verifiable composition of deterministic grammars. In Proceedings of Conference on Programming Language Design and Implementation (PLDI), pages 199--210. ACM, 2009. Google Scholar
Digital Library
- T. Sheard and S. Peyton Jones. Template meta-programming for Haskell. In Proceedings of Haskell Workshop, pages 1--16. ACM, 2002. Google Scholar
Digital Library
- W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1-2):211--242, 2000. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In Proceedings of International Conference on Functional Programming (ICFP), pages 117--128. ACM, 2010. Google Scholar
Digital Library
- E. Visser. Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam, 1997.Google Scholar
- E. Visser. Meta-programming with concrete object syntax. In Proceedings of Conference on Generative Programming and Component Engineering (GPCE), volume 2487 of LNCS, pages 299--315. Springer, 2002. Google Scholar
Digital Library
- E. Visser, Z.-E.-A. Benaissa, and A. P. Tolmach. Building program optimizers with rewriting strategies. In Proceedings of International Conference on Functional Programming (ICFP), pages 13--26. ACM, 1998. Google Scholar
Digital Library
- A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38--94, 1994. Google Scholar
Digital Library
Index Terms
Modular and automated type-soundness verification for language extensions
Recommendations
Modular and automated type-soundness verification for language extensions
ICFP '13: Proceedings of the 18th ACM SIGPLAN international conference on Functional programmingLanguage extensions introduce high-level programming constructs that protect programmers from low-level details and repetitive tasks. For such an abstraction barrier to be sustainable, it is important that no errors are reported in terms of generated ...
Sound type-dependent syntactic language extension
POPL '16: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming LanguagesSyntactic language extensions can introduce new facilities into a programming language while requiring little implementation effort and modest changes to the compiler. It is typical to desugar language extensions in a distinguished compiler phase after ...
Sound type-dependent syntactic language extension
POPL '16Syntactic language extensions can introduce new facilities into a programming language while requiring little implementation effort and modest changes to the compiler. It is typical to desugar language extensions in a distinguished compiler phase after ...







Comments