skip to main content
10.1145/3192366.3192398acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article
Public Access

Inferring type rules for syntactic sugar

Published: 11 June 2018 Publication History

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.

Supplementary Material

WEBM File (p812-pombrio.webm)

References

[1]
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.
[2]
Eugene Burmako. 2013. Scala macros: let our powers combine!. In Scala Workshop. ACM, New York, NY, USA.
[3]
Benjamin C. Pierce. 2002. Types and Programming Languages. MIT Press.
[4]
Stephen Chang, Alex Knauth, and Ben Greenman. 2017. Type systems as macros. In Principles of Programming Languages. ACM, New York, NY, USA.
[5]
Daniel de Rauglaudre. 2007. Camlp5 - Reference Manua. (2007). http://pauillac.inria.fr/ddr/camlp5/doc/pdf/camlp5-5.06.pdf.
[6]
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press.
[7]
David Fisher and Olin Shivers. 2006. Static analysis for syntax objects. In International Conference on Functional Programming. ACM, New York, NY, USA.
[8]
Matthew Flatt and PLT. June 7, 2010. Reference: Racket. Technical Report PLT-TR2010-1. PLT Inc. racket-lang.org/tr1/.
[9]
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.
[10]
Arjun Guha, Claudiu Saftoiu, and Shriram Krishnamurthi. 2010. The Essence of JavaScript. In European Conference on Object-oriented Programming. Springer-Verlag, Berlin, Heidelberg, 25.
[11]
Bastiaan Heeren, Jurriaan Hage, and S. Doaitse Swierstra. 2003. Scripting the Type Inference Process. In International Conference on Functional Programming. ACM, NewYork, NY, USA.
[12]
David Herman and Mitchell Wand. 2008. A Theory of Hygienic Macros. In European Symposium on Programming Languages and Systems. Springer-Verlag, Berlin, Heidelberg, 48s62.
[13]
Gilles Kahn. 1987. Natural Semantics. In International Symposium on Theoretical Aspects of Computer Software.
[14]
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.
[15]
Florian Lorenzen and Sebastian Erdweg. 2016. Sound type-dependent syntactic language extension. In Principles of Programming Languages. ACM, New York, NY, USA.
[16]
Geoffrey Mainland. 2012. Explicitly Heterogeneous Metaprogramming with MetaHaskell. In International Conference on Functional Programming. ACM, New York, NY, USA.
[17]
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.
[18]
Peyton Jones, Simon. 2003. Haskell 98 Language and Libraries: The Revised Report. Cambridge University Press.
[19]
Gordon D. Plotkin. 1981. A Structured Approach to Operational Semantics. Technical Report DAIMI FN-19. Computer Science Department, Aarhus University, Aarhus, Denmark.
[20]
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.
[21]
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.
[22]
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.
[23]
Justin Pombrio, Shriram Krishnamurthi, and Mitchell Wand. 2017. Inferring Scope through Syntactic Sugar. In International Conference on Functional Programming. ACM, New York, NY, USA.
[24]
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.
[25]
Tim Sheard and Simon Peyton Jones. 2002. Template Metaprogramming for Haskell. In ACM SIGPLAN Haskell Workshop. ACM, New York, NY, USA.
[26]
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/.
[27]
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.
[28]
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.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM Conferences
PLDI 2018: Proceedings of the 39th ACM SIGPLAN Conference on Programming Language Design and Implementation
June 2018
825 pages
ISBN:9781450356985
DOI:10.1145/3192366
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected].

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 11 June 2018

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. Macros
  2. Programming Languages
  3. Resugaring
  4. Syntactic Sugar
  5. Type Systems

Qualifiers

  • Research-article

Funding Sources

Conference

PLDI '18
Sponsor:

Acceptance Rates

Overall Acceptance Rate 406 of 2,067 submissions, 20%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)94
  • Downloads (Last 6 weeks)19
Reflects downloads up to 14 Sep 2024

Other Metrics

Citations

Cited By

View all

View Options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Get Access

Login options

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media