Expressive and Strongly Type-Safe Code Generation
Title | Expressive and Strongly Type-Safe Code Generation |
Publication Type | Conference Paper |
Year of Publication | 2017 |
Authors | Winant, Thomas, Cockx, Jesper, Devriese, Dominique |
Conference Name | Proceedings of the 19th International Symposium on Principles and Practice of Declarative Programming |
Publisher | ACM |
Conference Location | New York, NY, USA |
ISBN Number | 978-1-4503-5291-8 |
Keywords | Collaboration, Dependent types, human factors, meta-programming, Metrics, policy-based governance, Policy-Governed Secure Collaboration, pubcrawl, resilience, Resiliency, Safe Coding |
Abstract | Meta-programs are programs that generate other programs, but in weakly type-safe systems, type-checking a meta-program only establishes its own type safety, and generated programs need additional type-checking after generation. Strong type safety of a meta-program implies type safety of any generated object program, a property with important engineering benefits. Current strongly type-safe systems suffer from expressivity limitations and cannot support many meta-programs found in practice, for example automatic generation of lenses. To overcome this, we move away from the idea of staged meta-programming. Instead, we use an off-the-shelf dependently-typed language as the meta-language and a relatively standard, intrinsically well-typed representation of the object language. We scale this approach to practical meta-programming, by choosing a high-level, explicitly typed intermediate representation as the object language, rather than a surface programming language. We implement our approach as a library for the Glasgow Haskell Compiler (GHC) and evaluate it on several meta-programs, including a deriveLenses meta-program taken from a real-world Haskell lens library. Our evaluation demonstrates expressivity beyond the state of the art and applicability to real settings, at little cost in terms of code size. |
URL | https://dl.acm.org/citation.cfm?doid=3131851.3131872 |
DOI | 10.1145/3131851.3131872 |
Citation Key | winant_expressive_2017 |