Affiliation:
1. University of Chicago, USA
2. Carnegie Mellon University, USA
Abstract
General-purpose programming languages typically define literal notation for only a small number of common data structures, like lists. This is unsatisfying because there are many other data structures for which literal notation might be useful, e.g. finite maps, regular expressions, HTML elements, SQL queries, syntax trees for various languages and chemical structures. There may also be different implementations of each of these data structures behind a common interface that could all benefit from common literal notation. This paper introduces
typed literal macros (TLMs)
, which allow library providers to define new literal notation of nearly arbitrary design at any specified type or parameterized family of types. Compared to existing approaches, TLMs are uniquely
reasonable
. TLM clients can reason abstractly, i.e. without examining grammars or generated expansions, about types and binding. The system only needs to convey to clients, via secondary notation, the inferred
segmentation
of each literal body, which gives the locations and types of spliced subterms. TLM providers can reason modularly about syntactic ambiguity and expansion correctness according to clear criteria. This paper incorporates TLMs into Reason, an emerging alternative front-end for OCaml, and demonstrates, through several non-trivial case studies, how TLMs integrate with the advanced features of OCaml, including pattern matching and the module system. We also discuss optional integration with MetaOCaml, which allows TLM providers to be more confident about type correctness. Finally, we establish these abstract reasoning principles formally with a detailed type-theoretic account of expression and pattern TLMs for “core ML”.
Funder
National Security Agency
Defense Advanced Research Projects Agency
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference82 articles.
1. Michael D. Adams. 2015. Towards the Essence of Hygiene. In POPL. 10.1145/2676726.2677013 Michael D. Adams. 2015. Towards the Essence of Hygiene. In POPL. 10.1145/2676726.2677013
2. Eric Anderson Gilman D Veith and David Weininger. 1987. SMILES a line notation and computerized interpreter for chemical structures. US Environmental Protection Agency Environmental Research Laboratory. Eric Anderson Gilman D Veith and David Weininger. 1987. SMILES a line notation and computerized interpreter for chemical structures. US Environmental Protection Agency Environmental Research Laboratory.
3. Markup.ml — Error-recovering streaming HTML5 and XML parsers for OCaml. http://aantron.github. io/markup.ml/;Bachin Anton;Retrieved Mar.,2018
4. Alan Bawden. 1999. Quasiquotation in Lisp. In Partial Evaluation and Semantic-Based Program Manipulation. http: //repository.readscheme.org/ftp/papers/pepm99/bawden.pdf Alan Bawden. 1999. Quasiquotation in Lisp. In Partial Evaluation and Semantic-Based Program Manipulation. http: //repository.readscheme.org/ftp/papers/pepm99/bawden.pdf
5. Frédéric Bour Thomas Refis and Gabriel Scherer. 2018. Experience report: Merlin a Language Server for OCaml. In ICFP. Frédéric Bour Thomas Refis and Gabriel Scherer. 2018. Experience report: Merlin a Language Server for OCaml. In ICFP.
Cited by
5 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Lorgnette: Creating Malleable Code Projections;Proceedings of the 36th Annual ACM Symposium on User Interface Software and Technology;2023-10-29
2. Rhombus: A New Spin on Macros without All the Parentheses;Proceedings of the ACM on Programming Languages;2023-10-16
3. Contextualized Programming Language Documentation;Proceedings of the 2022 ACM SIGPLAN International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software;2022-11-29
4. Notational Programming for Notebook Environments: A Case Study with Quantum Circuits;The 35th Annual ACM Symposium on User Interface Software and Technology;2022-10-28
5. Filling typed holes with live GUIs;Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and Implementation;2021-06-18