skip to main content
research-article

Modular and automated type-soundness verification for language extensions

Published:25 September 2013Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. K. Crary and S. Weirich. Flexible type analysis. In Proceedings of International Conference on Functional Programming (ICFP), pages 233--248. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. D. de Rauglaudre. Camlp4 reference manual. http://caml.inria.fr/pub/docs/manual-camlp4/index.html, 2003. accessed Mar. 26 2013.Google ScholarGoogle Scholar
  5. S. Erdweg. Extensible Languages for Flexible and Principled Domain Abstraction. PhD thesis, Philipps-Universiät Marburg, 2013.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Felleisen, R. B. Findler, and M. Flatt. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. Fisher and O. Shivers. Building language towers with Ziggurat. Functional Programming, 18(5-6):707--780, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. D. Herman. A Theory of Typed Hygienic Macros. PhD thesis, Northeastern University, Boston, Massachusetts, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Los and R. Suszko. Remarks on sentential logics. Indagationes Mathematicae, 20:177--183, 1958.Google ScholarGoogle ScholarCross RefCross Ref
  18. G. Mainland. Explicitly heterogeneous metaprogramming with Meta-Haskell. In Proceedings of International Conference on Functional Programming (ICFP), pages 311--322. ACM, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. E. Moggi. Notions of computation and monads. Information and Computation, 93(1):55--92, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. B. C. Pierce. Types and programming languages. MIT press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Sheard and S. Peyton Jones. Template meta-programming for Haskell. In Proceedings of Haskell Workshop, pages 1--16. ACM, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. W. Taha and T. Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1-2):211--242, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. E. Visser. Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam, 1997.Google ScholarGoogle Scholar
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 115(1):38--94, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Modular and automated type-soundness verification for language extensions

                Recommendations

                Comments

                Login options

                Check if you have access through your login credentials or your institution to get full access on this article.

                Sign in

                Full Access

                PDF Format

                View or Download as a PDF file.

                PDF

                eReader

                View online with eReader.

                eReader
                About Cookies On This Site

                We use cookies to ensure that we give you the best experience on our website.

                Learn more

                Got it!