Abstract
Type systems and syntactic sugar are both valuable to programmers, but sometimes at odds. While sugar is a valuable mechanism for implementing realistic languages, the expansion process obscures program source structure. As a result, type errors can reference terms the programmers did not write (and even constructs they do not know), baffling them. The language developer must also manually construct type rules for the sugars, to give a typed account of the surface language. We address these problems by presenting a process for automatically reconstructing type rules for the surface language using rules for the core. We have implemented this theory, and show several interesting case studies.
Supplemental Material
- Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. 2016. Practical Optional Types for Clojure. In European Symposium on Programming Languages and Systems. Springer-Verlag, Berlin, Heidelberg. Google Scholar
Digital Library
- Eugene Burmako. 2013. Scala macros: let our powers combine!. In Scala Workshop. ACM, New York, NY, USA. Google Scholar
Digital Library
- Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press. Google Scholar
Digital Library
- Stephen Chang, Alex Knauth, and Ben Greenman. 2017. Type systems as macros. In Principles of Programming Languages. ACM, New York, NY, USA. Google Scholar
Digital Library
- Daniel de Rauglaudre. 2007. Camlp5 - Reference Manua. (2007). http://pauillac.inria.fr/ddr/camlp5/doc/pdf/camlp5-5.06.pdf.Google Scholar
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press. Google Scholar
Digital Library
- David Fisher and Olin Shivers. 2006. Static analysis for syntax objects. In International Conference on Functional Programming. ACM, New York, NY, USA. Google Scholar
Digital Library
- Matthew Flatt and PLT. June 7, 2010. Reference: Racket. Technical Report PLT-TR2010-1. PLT Inc. racket-lang.org/tr1/.Google Scholar
- Steve Ganz, Amr Sabry, and Walid Taha. 2001. Macros as Multi-Stage Computations: Type-Safe, Generative, Binding Macros in MacroML. In International Conference on Functional Programming. ACM, New York, NY, USA. Google Scholar
Digital Library
- Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The Essence of JavaScript. In European Conference on Object-oriented Programming. Springer-Verlag, Berlin, Heidelberg, 25. Google Scholar
Digital Library
- Bastiaan Heeren, Jurriaan Hage, and S. Doaitse Swierstra. 2003. Scripting the Type Inference Process. In International Conference on Functional Programming. ACM, NewYork, NY, USA. Google Scholar
Digital Library
- David Herman and Mitchell Wand. 2008. A Theory of Hygienic Macros. In European Symposium on Programming Languages and Systems. Springer-Verlag, Berlin, Heidelberg, 48s62. Google Scholar
Digital Library
- Gilles Kahn. 1987. Natural Semantics. In International Symposium on Theoretical Aspects of Computer Software. Google Scholar
Digital Library
- Florian Lorenzen and Sebastian Erdweg. 2013. Modular and Automated Type-Soundness for Language Extensions. In International Conference on Functional Programming. ACM, New York, NY, USA, 12. Google Scholar
Digital Library
- Florian Lorenzen and Sebastian Erdweg. 2016. Sound type-dependent syntactic language extension. In Principles of Programming Languages. ACM, New York, NY, USA. Google Scholar
Digital Library
- Geoffrey Mainland. 2012. Explicitly Heterogeneous Metaprogramming with MetaHaskell. In International Conference on Functional Programming. ACM, New York, NY, USA. Google Scholar
Digital Library
- Cyrus Omar, Darya Kurilova, Ligia Nistor, Benjamin Chung, Alex Potanin, and Jonathan Aldrich. 2014. Safely Composable Type-Specific Languages. In European Conference on Object-Oriented Programming. Springer-Verlag, New York, NY, USA. Google Scholar
Digital Library
- Peyton Jones, Simon. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.Google Scholar
- Gordon D. Plotkin. 1981. A Structured Approach to Operational Semantics. Technical Report DAIMI FN-19. Computer Science Department, Aarhus University, Aarhus, Denmark.Google Scholar
- Joe Gibbs Politz, Matt Carroll, Benjamin S. Lerner, Justin Pombrio, and Shriram Krishnamurthi. 2012. A Tested Semantics for Getters, Setters, and Eval in JavaScript. In Dynamic Languages Symposium. Google Scholar
Digital Library
- Joe Gibbs Politz, Alejandro Martinez, Matthew Milano, Sumner Warren, Daniel Patterson, Junsong Li, Anand Chitipothu, and Shriram Krishnamurthi. 2013. Python: The Full Monty: A Tested Semantics for the Python Programming Language. In ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications. ACM, New York, NY, USA, 217s232. Google Scholar
Digital Library
- Justin Pombrio and Shriram Krishnamurthi. 2014. Resugaring: Lifting Evaluation Sequences through Syntactic Sugar. In Programming Languages Design and Implementation. ACM, New York, NY, USA, 361-371. Google Scholar
Digital Library
- Justin Pombrio, Shriram Krishnamurthi, and Mitchell Wand. 2017. Inferring Scope through Syntactic Sugar. In International Conference on Functional Programming. ACM, New York, NY, USA. Google Scholar
Digital Library
- Alejandro Serrano and Jurriaan Hage. 2016. Type Error Diagnosis for Embedded DSLs by Two-Stage Specialized Type Rules. In European Symposium on Programming Languages and Systems. ACM, New York, NY, USA. Google Scholar
Digital Library
- Tim Sheard and Simon Peyton Jones. 2002. Template Metaprogramming for Haskell. In ACM SIGPLAN Haskell Workshop. ACM, New York, NY, USA. Google Scholar
Digital Library
- Joel Spolsky. 2002. The Law of Leaky Abstractions. Blog post: Joel on Software. (2002). https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/.Google Scholar
- Paul Stansifer and Mitchell Wand. 2014. Romeo: a System For More Flexible Binding-Safe Programming. In International Conference on Functional Programming. ACM, New York, NY, USA, 53s65. Google Scholar
Digital Library
- Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt, and Matthias Felleisen. 2011. Languages as Libraries. In Programming Languages Design and Implementation. ACM, New York, NY, USA. Google Scholar
Digital Library
Index Terms
Inferring type rules for syntactic sugar
Recommendations
Inferring type rules for syntactic sugar
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and ImplementationType systems and syntactic sugar are both valuable to programmers, but sometimes at odds. While sugar is a valuable mechanism for implementing realistic languages, the expansion process obscures program source structure. As a result, type errors can ...
Resugaring: lifting evaluation sequences through syntactic sugar
PLDI '14: Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and ImplementationSyntactic sugar is pervasive in language technology. It is used to shrink the size of a core language; to define domain-specific languages; and even to let programmers extend their language. Unfortunately, syntactic sugar is eliminated by transformation,...
Inferring scope through syntactic sugar
Many languages use syntactic sugar to define parts of their surface language in terms of a smaller core. Thus some properties of the surface language, like its scoping rules, are not immediately evident. Nevertheless, IDEs, refactorers, and other tools ...







Comments