Abstract
In the context of gradual typing, type soundness guarantees the safety of typed code. When untyped code fails to respect types, a runtime check finds the discrepancy. As for untyped code, type soundness makes no promises; it does not protect untyped code from mistakes in type specifications and unwarranted blame.
To address the asymmetry, this paper adapts complete monitoring from the contract world to gradual typing. Complete monitoring strengthens plain soundness into a guarantee that catches problems with faulty type specifications. Furthermore, a semantics that satisfies complete monitoring can easily pinpoint the conflict between a type specification and a value. For gradual typing systems that fail complete monitoring, the technical framework provides a source-of-truth to assess the quality of blame.
Supplemental Material
- Esteban Allende, Johan Fabry, and Éric Tanter. 2013. Cast Insertion Strategies for Gradually-Typed Objects. In DLS. 27–36.Google Scholar
- Henk Barendregt. 1981. The Lambda Calculus: Its Syntax and Semantics. North-Holland Publishing Company.Google Scholar
- Gavin Bierman, Martin Abadi, and Mads Torgersen. 2014. Understanding TypeScript. In ECOOP. 257–281.Google Scholar
- Matthias Blume and David A. McAllester. 2006. Sound and Complete Models of Contracts. JFP 16, 4-5 (2006), 375–414.Google Scholar
Digital Library
- Ambrose Bonnaire-Sergeant, Rowan Davies, and Sam Tobin-Hochstadt. 2016. Practical Optional Types for Clojure. In ESOP. 68–94.Google Scholar
- Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. PACMPL 1, ICFP (2017), 41:1–41:28.Google Scholar
- Avik Chaudhuri, Panagiotis Vekris, Sam Goldman, Marshall Roch, and Gabriel Levy. 2017. Fast and Precise Type Checking for JavaScript. PACMPL 1, OOPSLA (2017), 56:1–56:30.Google Scholar
- Sheng Chen and John Peter Campora, III. 2019. Blame Tracking and Type Error Debugging. In SNAPL. 2:1–2:14.Google Scholar
- Benjamin W. Chung, Paley Li, Francesco Zappa Nardelli, and Jan Vitek. 2018. KafKa: Gradual Typing for Objects. In ECOOP. 12:1–12:23.Google Scholar
- Matteo Cimini and Jeremy Siek. 2017. Automatically Generating the Dynamic Semantics of Gradually Typed Languages. In POPL. 789–803.Google Scholar
- Christos Dimoulas, Robert Bruce Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct Blame for Contracts: No More Scapegoating. In POPL. 215–226.Google Scholar
- Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In ESOP. 214–233.Google Scholar
- Asger Feldthaus and Anders Møller. 2014. Checking Correctness of TypeScript Interfaces for JavaScript Libraries. In OOPSLA. 1–16.Google Scholar
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press.Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for Higher-Order Functions. In ICFP. 48–59.Google Scholar
- Michael Greenberg. 2015. Space-Efficient Manifest Contracts. In POPL. 181–194.Google Scholar
- Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2012. Contracts made manifest. JFP 22, 3 (2012), 225–274.Google Scholar
Digital Library
- Ben Greenman and Matthias Felleisen. 2018. A Spectrum of Type Soundness and Performance. PACMPL 2, ICFP (2018), 71:1–71:32.Google Scholar
Digital Library
- Ben Greenman, Matthias Felleisen, and Christos Dimoulas. 2019a. Complete Monitors for Gradual Types: Supplementary Material. Technical Report NU-CCIS-2019-001. Northeastern University.Google Scholar
- Ben Greenman, Asumu Takikawa, Max S. New, Daniel Feltey, Robert Bruce Findler, Jan Vitek, and Matthias Felleisen. 2019b. How to evaluate the performance of gradual type systems. JFP 29, e4 (2019), 1–45.Google Scholar
Digital Library
- Dan Grossman, Greg Morrisett, and Steve Zdancewic. 2000. Syntactic Type Abstraction. TOPLAS 22, 6 (2000), 1037–1080.Google Scholar
Digital Library
- David Herman, Aaron Tomb, and Cormac Flanagan. 2010. Space-efficient Gradual Typing. HOSC 23, 2 (2010), 167–189.Google Scholar
Digital Library
- Ralf Hinze, Johan Jeuring, and Andres Löh. 2006. Typed Contracts for Functional Programming. In FLOPS. 208–225.Google Scholar
- Andre Murbach Maidl, Fabio Mascarenhas, and Roberto Ierusalimschy. 2015. A Formalization of Typed Lua. In DLS. 13–25.Google Scholar
- Jacob Matthews and Robert Bruce Findler. 2009. Operational Semantics for Multi-Language Programs. TOPLAS 31, 3 (2009), 1–44.Google Scholar
Digital Library
- Robin Milner. 1978. A Theory of Type Polymorphism in Programming. J. Comput. System Sci. 17, 3 (1978), 348–375.Google Scholar
- Scott Moore, Christos Dimoulas, Robert Bruce Findler, Matthew Flatt, and Stephen Chong. 2016. Extensible Access Control with Authorization Contracts. In OOPSLA. 214–233.Google Scholar
- Fabian Muehlboeck and Ross Tate. 2017. Sound Gradual Typing is Nominally Alive and Well. PACMPL 1, OOPSLA (2017), 56:1–56:30.Google Scholar
Digital Library
- Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. PACMPL 2, ICFP (2018), 73:1–73:30.Google Scholar
- Max S. New, Daniel R. Licata, and Amal Ahmed. 2019. Gradual Type Theory. PACMPL 3, POPL (2019), 15:1–15:31.Google Scholar
Digital Library
- Aseem Rastogi, Nikhil Swamy, Cédric Fournet, Gavin Bierman, and Panagiotis Vekris. 2015. Safe & Efficient Gradual Typing for TypeScript. In POPL. 167–180.Google Scholar
- Gregor Richards, Ellen Arteca, and Alexi Turcotte. 2017. The VM Already Knew That: Leveraging Compile-Time Knowledge to Optimize Gradual Typing. PACMPL 1, OOPSLA (2017), 55:1–55:27.Google Scholar
Digital Library
- Gregor Richards, Francesco Zappa Nardelli, and Jan Vitek. 2015. Concrete Types for TypeScript. In ECOOP. 76–100.Google Scholar
- Richard Roberts, Stefan Marr, Michael Homer, and James Noble. 2019. Transient Typechecks are (Almost) Free. In ECOOP. 15:1–15:29.Google Scholar
- Jeremy Siek, Peter Thiemann, and Philip Wadler. 2015a. Blame and Coercion: Together Again for the First Time. In PLDI. 425–435.Google Scholar
- Jeremy Siek, Michael M. Vitousek, Matteo Cimini, Sam Tobin-Hochstadt, and Ronald Garcia. 2015c. Monotonic References for Efficient Gradual Typing. In ESOP. 432–456.Google Scholar
- Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015b. Refined Criteria for Gradual Typing. In SNAPL. 274–293.Google Scholar
- Vincent St-Amour and Neil Toronto. 2013. Experience Report: Applying Random Testing to a Base Type Environment. In ICFP. 351–356.Google Scholar
- Cameron Swords, Amr Sabry, and Sam Tobin-Hochstadt. 2018. An extended account of contract monitoring strategies as patterns of communication. JFP 28, e4 (2018), 1–47.Google Scholar
- Asumu Takikawa, Daniel Feltey, Earl Dean, Robert Bruce Findler, Matthew Flatt, Sam Tobin-Hochstadt, and Matthias Felleisen. 2015. Towards Practical Gradual Typing. In ECOOP. 4–27.Google Scholar
- Asumu Takikawa, T. Stephen Strickland, Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Gradual Typing for First-Class Classes. In OOPSLA. 793–810.Google Scholar
- Asumu Takikawa, T. Stephen Strickland, and Sam Tobin-Hochstadt. 2013. Constraining Delimited Control with Contracts. In ESOP. 229–248.Google Scholar
- Satish Thatte. 1990. Quasi-static Typing. In POPL. 367–381.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage Migration: from Scripts to Programs. In DLS. 964–974.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. 2008. The Design and Implementation of Typed Scheme. In POPL. 395–406.Google Scholar
- Sam Tobin-Hochstadt and Matthias Felleisen. 2010. Logical Types for Untyped Languages. In ICFP. 117–128.Google Scholar
- Sam Tobin-Hochstadt, Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Ben Greenman, Andrew M. Kent, Vincent St-Amour, T. Stephen Strickland, and Asumu Takikawa. 2017. Migratory Typing: Ten years later. In SNAPL. 17:1–17:17.Google Scholar
- Michael M. Vitousek. 2019. Gradual Typing for Python, Unguarded. Ph.D. Dissertation. Indiana University.Google Scholar
- Michael M. Vitousek, Cameron Swords, and Jeremy G. Siek. 2017. Big Types in Little Runtime: Open-World Soundness and Collaborative Blame for Gradual Type Systems. In POPL. 762–774.Google Scholar
Digital Library
- Philip Wadler. 2015. A Complement to Blame. In SNAPL. 309–320.Google Scholar
- Philip Wadler and Robert Bruce Findler. 2009. Well-typed Programs Can’t be Blamed. In ESOP. 1–15.Google Scholar
- Lucas Waye, Stephen Chong, and Christos Dimoulas. 2017. Whip: Higher-Order Contracts for Modern Services. PACMPL 1, ICFP (2017), 36:1–36:28.Google Scholar
- Tobias Wrigstad, Francesco Zappa Nardelli, Sylvain Lebresne, Johan Ostlund, and Jan Vitek. 2010. Integrating Typed and Untyped Code in a Scripting Language. In POPL. 377–388.Google Scholar
Digital Library
Index Terms
Complete monitors for gradual types
Recommendations
Typed–Untyped Interactions: A Comparative Analysis
The literature presents many strategies for enforcing the integrity of types when typed code interacts with untyped code. This article presents a uniform evaluation framework that characterizes the differences among some major existing semantics for typed–...
Deep and shallow types for gradual languages
PLDI 2022: Proceedings of the 43rd ACM SIGPLAN International Conference on Programming Language Design and ImplementationSound gradual types come in many forms and offer varying levels of soundness. Two extremes are deep types and shallow types. Deep types offer compositional guarantees but depend on expensive higher-order contracts. Shallow types enforce only local ...
Gradual typing with union and intersection types
We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to ...






Comments