Abstract
Static typing can guide programmers if feedback is immediate. Therefore, all major IDEs incrementalize type checking in some way. However, prior approaches to incremental type checking are often specialized and hard to transfer to new type systems. In this paper, we propose a systematic approach for deriving incremental type checkers from textbook-style type system specifications. Our approach is based on compiling inference rules to Datalog, a carefully limited logic programming language for which incremental solvers exist. The key contribution of this paper is to discover an encoding of the infinite typing relation as a finite Datalog relation in a way that yields efficient incremental updates. We implemented the compiler as part of a type system DSL and show that it supports simple types, some local type inference, operator overloading, universal types, and iso-recursive types.
Supplemental Material
- Mario Alvarez-Picallo, Alex Eyers-Taylor, Michael Peyton Jones, and C.-H. Luke Ong. 2019. Fixing Incremental Computation-Derivatives of Fixpoints, and the Recursive Semantics of Datalog. In Programming Languages and Systems-28th European Symposium on Programming, ESOP 2019, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2019, Prague, Czech Republic, April 6-11, 2019, Proceedings (Lecture Notes in Computer Science), Luís Caires (Ed.), Vol. 11423. Springer, 525-552. https://doi.org/10.1007/978-3-030-17184-1_19 Google Scholar
Cross Ref
- Michael Arntzenius and Neel Krishnaswami. 2020. Seminaïve evaluation for a higher-order functional language. Proc. ACM Program. Lang. 4, POPL ( 2020 ), 22 : 1-22 : 28. https://doi.org/10.1145/3371090 Google Scholar
Digital Library
- Isabelle Attali, Jacques Chazarain, and Serge Gilette. 1992. Incremental Evaluation of Natural Semantics Specification. In Programming Language Implementation and Logic Programming, 4th International Symposium, PLILP'92, Leuven, Belgium, August 26-28, 1992, Proceedings (Lecture Notes in Computer Science), Maurice Bruynooghe and Martin Wirsing (Eds.), Vol. 631. Springer, 87-99. https://doi.org/10.1007/3-540-55844-6_129 Google Scholar
Cross Ref
- Catriel Beeri and Raghu Ramakrishnan. 1991. On the Power of Magic. J. Log. Program. 10, 3 & 4 ( 1991 ), 255-299. https: //doi.org/10.1016/ 0743-1066 ( 91 ) 90038-Q Google Scholar
Digital Library
- Matteo Busi, Pierpaolo Degano, and Letterio Galletta. 2019. Using Standard Typing Algorithms Incrementally. In NASA Formal Methods-11th International Symposium, NFM 2019, Houston, TX, USA, May 7-9, 2019, Proceedings (Lecture Notes in Computer Science), Julia M. Badger and Kristin Yvonne Rozier (Eds.), Vol. 11460. Springer, 106-122. https: //doi.org/10.1007/978-3-030-20652-9_7 Google Scholar
Cross Ref
- Thierry Despeyroux. 1984. Executable Specification of Static Semantics. In Semantics of Data Types, International Symposium, Sophia-Antipolis, France, June 27-29, 1984, Proceedings (Lecture Notes in Computer Science), Gilles Kahn, David B. MacQueen, and Gordon D. Plotkin (Eds.), Vol. 173. Springer, 215-233. https://doi.org/10.1007/3-540-13346-1_11 Google Scholar
Cross Ref
- Sebastian Erdweg, Oliver Bracevac, Edlira Kuci, Matthias Krebs, and Mira Mezini. 2015. A co-contextual formulation of type rules and its application to incremental type checking. In Proceedings of the 2015 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2015, part of SPLASH 2015, Pittsburgh, PA, USA, October 25-30, 2015, Jonathan Aldrich and Patrick Eugster (Eds.). ACM, 880-897. https://doi.org/10.1145/2814270. 2814277 Google Scholar
Digital Library
- Frantisek Farka, Ekaterina Komendantskaya, and Kevin Hammond. 2018. Proof-relevant Horn Clauses for Dependent Type Inference and Term Synthesis. Theory Pract. Log. Program. 18, 3-4 ( 2018 ), 484-501. https://doi.org/10.1017/ S1471068418000212 Google Scholar
Cross Ref
- Luca Franceschini, Davide Ancona, and Ekaterina Komendantskaya. 2016. Structural Resolution for Abstract Compilation of Object-Oriented Languages. In Proceedings of the First Workshop on Coalgebra, Horn Clause Logic Programming and Types, CoALP-Ty 2016, Edinburgh, UK, 28-29 November 2016 (EPTCS), Ekaterina Komendantskaya and John Power (Eds.), Vol. 258. 19-35. https://doi.org/10.4204/EPTCS.258.2 Google Scholar
Cross Ref
- Sylvia Grewe, Sebastian Erdweg, Pascal Wittmann, and Mira Mezini. 2015. Type systems for the masses: deriving soundness proofs and eficient checkers. In 2015 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software, Onward! 2015, Pittsburgh, PA, USA, October 25-30, 2015, Gail C. Murphy and Guy L. Steele Jr. (Eds.). ACM, 137-150. https://doi.org/10.1145/2814228.2814239 Google Scholar
Digital Library
- Robert Harper. 2016. Practical Foundations for Programming Languages (2nd. Ed.). Cambridge University Press. https: //www.cs.cmu.edu/%7Erwh/pfpl/index.htmlGoogle Scholar
- Edlira Kuci, Sebastian Erdweg, Oliver Bracevac, Andi Bejleri, and Mira Mezini. 2017. A Co-contextual Type Checker for Featherweight Java. In 31st European Conference on Object-Oriented Programming, ECOOP 2017, June 19-23, 2017, Barcelona, Spain (LIPIcs), Peter Müller (Ed.), Vol. 74. Schloss Dagstuhl-Leibniz-Zentrum für Informatik, 18 : 1-18 : 26. https://doi.org/10.4230/LIPIcs.ECOOP. 2017.18 Google Scholar
Cross Ref
- Lambert G. L. T. Meertens. 1983. Incremental Polymorphic Type Checking in B. In Conference Record of the Tenth Annual ACM Symposium on Principles of Programming Languages, Austin, Texas, USA, January 1983, John R. Wright, Larry Landweber, Alan J. Demers, and Tim Teitelbaum (Eds.). ACM Press, 265-275. https://doi.org/10.1145/567067.567092 Google Scholar
Digital Library
- Benjamin C. Pierce. 2002. Types and programming languages. MIT Press.Google Scholar
Digital Library
- Raghu Ramakrishnan, François Bancilhon, and Abraham Silberschatz. 1987. Safety of Recursive Horn Clauses With Infinite Relations. In Proceedings of the Sixth ACM SIGACT-SIGMOD-SIGART Symposium on Principles of Database Systems, March 23-25, 1987, San Diego, California, USA, Moshe Y. Vardi (Ed.). ACM, 328-339. https://doi.org/10.1145/28659.28694 Google Scholar
Digital Library
- Leonid Ryzhyk and Mihai Budiu. 2019. Diferential Datalog. In Datalog 2.0 2019-3rd International Workshop on the Resurgence of Datalog in Academia and Industry co-located with the 15th International Conference on Logic Programming and Nonmonotonic Reasoning (LPNMR 2019) at the Philadelphia Logic Week 2019, Philadelphia, PA (USA), June 4-5, 2019 (CEUR Workshop Proceedings), Mario Alviano and Andreas Pieris (Eds.), Vol. 2368. CEUR-WS.org, 56-67. http://ceurws.org/Vol-2368 /paper6.pdfGoogle Scholar
- Yannis Smaragdakis and Martin Bravenboer. 2010. Using Datalog for Fast and Easy Program Analysis. In Datalog Reloaded-First International Workshop, Datalog 2010, Oxford, UK, March 16-19, 2010. Revised Selected Papers (Lecture Notes in Computer Science), Oege de Moor, Georg Gottlob, Tim Furche, and Andrew Jon Sellers (Eds.), Vol. 6702. Springer, 245-251. https://doi.org/10.1007/978-3-642-24206-9_14 Google Scholar
Digital Library
- Tamás Szabó, Gábor Bergmann, Sebastian Erdweg, and Markus Voelter. 2018a. Incrementalizing lattice-based program analyses in Datalog. PACMPL 2, OOPSLA ( 2018 ), 139 : 1-139 : 29. https://doi.org/10.1145/3276509 Google Scholar
Digital Library
- Tamás Szabó, Sebastian Erdweg, and Markus Voelter. 2016. IncA: a DSL for the definition of incremental program analyses. In Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, ASE 2016, Singapore, September 3-7, 2016, David Lo, Sven Apel, and Sarfraz Khurshid (Eds.). ACM, 320-331. https://doi.org/10.1145/2970276. 2970298 Google Scholar
Digital Library
- Tamás Szabó, Edlira Kuci, Matthijs Bijman, Mira Mezini, and Sebastian Erdweg. 2018b. Incremental overload resolution in object-oriented programming languages. In Companion Proceedings for the ISSTA/ECOOP 2018 Workshops, ISSTA 2018, Amsterdam, Netherlands, July 16-21, 2018, Julian Dolby, William G. J. Halfond, and Ashish Mishra (Eds.). ACM, 27-33. https://doi.org/10.1145/3236454.3236485 Google Scholar
Digital Library
- Guido Wachsmuth, Gabriël D. P. Konat, Vlad A. Vergu, Danny M. Groenewegen, and Eelco Visser. 2013. A Language Independent Task Engine for Incremental Name and Type Analysis. In Software Language Engineering-6th International Conference, SLE 2013, Indianapolis, IN, USA, October 26-28, 2013. Proceedings (Lecture Notes in Computer Science), Martin Erwig, Richard F. Paige, and Eric Van Wyk (Eds.), Vol. 8225. Springer, 260-280. https://doi.org/10.1007/978-3-319-02654-1_15 Google Scholar
Cross Ref
- Philip Wadler. 1990. Deforestation: Transforming Programs to Eliminate Trees. Theor. Comput. Sci. 73, 2 ( 1990 ), 231-248. https://doi.org/10.1016/ 0304-3975 ( 90 ) 90147-A Google Scholar
Digital Library
- Adrienne Watt. 2018. Database design.Google Scholar
Index Terms
A systematic approach to deriving incremental type checkers
Recommendations
Incremental type-checking for free: using scope graphs to derive incremental type-checkers
Fast analysis response times in IDEs are essential for a good editor experience. Incremental type-checking can provide that in a scalable fashion. However, existing techniques are not reusable between languages. Moreover, mutual and dynamic ...
Type systems for the masses: deriving soundness proofs and efficient checkers
Onward! 2015: 2015 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming and Software (Onward!)The correct definition and implementation of non-trivial type systems is difficult and requires expert knowledge, which is not available to developers of domain-specific languages (DSLs) in practice. We propose Veritas, a workbench that simplifies the ...
Incremental type-checking for type-reflective metaprograms
GPCE '10: Proceedings of the ninth international conference on Generative programming and component engineeringGarcia introduces a calculus for type-reflective metaprogramming that provides much of the power and flexibility of C++ templates and solves many of its problems. However, one of the problems that remains is that the residual program is not type checked ...






Comments