Abstract
Dependently-typed programming languages are gaining importance, because they can guarantee a wide range of properties at compile time. Their use in practice is often hampered because programmers have to provide very precise types. Gradual typing is a means to vary the level of typing precision between program fragments and to transition smoothly towards more precisely typed programs. The combination of gradual typing and dependent types seems promising to promote the widespread use of dependent types.
We investigate a gradual version of a minimalist value-dependent lambda calculus. Compile-time calculations and thus dependencies are restricted to labels, drawn from a generic enumeration type. The calculus supports the usual Pi and Sigma types as well as singleton types and subtyping. It is sufficiently powerful to provide flexible encodings of variant and record types with first-class labels.
We provide type checking algorithms for the underlying label-dependent lambda calculus and its gradual extension. The gradual type checker drives the translation into a cast calculus, which extends the original language. The cast calculus comes with several innovations: refined typing for casts in the presence of singletons, type reduction in casts, and fully dependent Sigma types. Besides standard metatheoretical results, we establish the gradual guarantee for the gradual language.
Supplemental Material
- Amal Ahmed, Robert Bruce Findler, Jeremy G. Siek, and Philip Wadler. 2011. Blame For All. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Thomas Ball and Mooly Sagiv (Eds.). ACM, Austin, TX, USA. 201–214.Google Scholar
Digital Library
- David Aspinall. 1994. Subtyping with Singleton Types. In Computer Science Logic, CSL’94 (LNCS, Vol. 933). Springer, Kazimierz, Poland. 1–15.Google Scholar
Cross Ref
- David Aspinall and Adriana B. Compagnoni. 2001. Subtyping Dependent Types. Theoretical Computer Science, 266, 1-2 (2001), 273–309. https://doi.org/10.1016/S0304-3975(00)00175-4 Google Scholar
Digital Library
- Yves Bertot and Pierre Castéran. 2004. Interactive Theorem Proving and Program Development. Coq’Art: The Calculus of Inductive Constructions. Springer. isbn:978-3-642-05880-6Google Scholar
- Edwin Brady. 2013. Idris, A General-Purpose Dependently Typed Programming Language: Design and Implementation. J. Funct. Program., 23, 5 (2013), 552–593. https://doi.org/10.1017/S095679681300018X Google Scholar
Cross Ref
- Chris Casinghino, Vilhelm Sjöberg, and Stephanie Weirich. 2014. Combining Proofs and Programs in a Dependently Typed Language. In POPL, Suresh Jagannathan and Peter Sewell (Eds.). ACM, San Diego, CA, USA. 33–46. isbn:978-1-4503-2544-8 https://doi.org/10.1145/2535838.2535883 Google Scholar
Digital Library
- Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. PACMPL, 1, ICFP (2017), 41:1–41:28. https://doi.org/10.1145/3110285 Google Scholar
Digital Library
- Matteo Cimini and Jeremy G. Siek. 2016. The Gradualizer: a Methodology and Algorithm for Generating Gradual Type Systems. In POPL. ACM, 443–455.Google Scholar
- Thierry Coquand and Gérard Huet. 1988. The Calculus of Constructions. Information and Computation, 76, 2/3 (1988), 95–120.Google Scholar
Digital Library
- Pierre-Évariste Dagand, Nicolas Tabareau, and Éric Tanter. 2018. Foundations of Dependent Interoperability. J. Funct. Program., 28 (2018), e9. https://doi.org/10.1017/S0956796818000011 Google Scholar
Cross Ref
- Jan de Muijnck-Hughes, Edwin C. Brady, and Wim Vanderbauwhede. 2019. Value-Dependent Session Design in a Dependently Typed Language. In Proceedings Programming Language Approaches to Concurrency- and Communication-cEntric Software, [email protected] 2019, Prague, Czech Republic, 7th April 2019, Francisco Martins and Dominic Orchard (Eds.) (EPTCS, Vol. 291). 47–59. https://doi.org/10.4204/EPTCS.291.5 Google Scholar
Cross Ref
- Joseph Eremondi, Éric Tanter, and Ronald Garcia. 2019. Approximate Normalization for Gradual Dependent Types. Proc. ACM Program. Lang., 3, ICFP (2019), 88:1–88:30. https://doi.org/10.1145/3341692 Google Scholar
Digital Library
- Ronald Garcia, Alison M. Clark, and Éric Tanter. 2016. Abstracting Gradual Typing. In POPL. ACM, 429–442.Google Scholar
- Fritz Henglein. 1994. Dynamic Typing: Syntax and Proof Theory. Science of Computer Programming, 22 (1994), 197–230.Google Scholar
Digital Library
- Atsushi Igarashi, Peter Thiemann, Vasco T. Vasconcelos, and Philip Wadler. 2017. Gradual Session Types. Proc. ACM Program. Lang., 1, ICFP (2017), Article 38, Sept., 28 pages. https://doi.org/10.1145/3110282 Google Scholar
Digital Library
- Yuu Igarashi, Taro Sekiyama, and Atsushi Igarashi. 2017. On Polymorphic Gradual Typing. PACMPL, 1, ICFP (2017), 40:1–40:29. https://doi.org/10.1145/3110284 Google Scholar
Digital Library
- Koen Jacobs, Amin Timany, and Dominique Devriese. 2021. Fully Abstract from Static to Gradual. Proc. ACM Program. Lang., 5, POPL (2021), 1–30. https://doi.org/10.1145/3434288 Google Scholar
Digital Library
- Kenneth L. Knowles and Cormac Flanagan. 2010. Hybrid type checking. ACM Trans. Program. Lang. Syst., 32, 2 (2010), 6:1–6:34.Google Scholar
Digital Library
- Fabian Krause, Weili Fu, and Peter Thiemann. 2021. Artifact for Label Dependent Lambda Calculus and Gradual Typing. https://doi.org/10.5281/zenodo.5497628 Google Scholar
Digital Library
- Nico Lehmann and Éric Tanter. 2017. Gradual Refinement Types. In POPL. ACM, Paris, France. 775–788.Google Scholar
- Meven Lennon-Bertrand, Kenji Maillard, Nicolas Tabareau, and Éric Tanter. 2020. Gradualizing the Calculus of Inductive Constructions. CoRR, abs/2011.10618 (2020), arxiv:2011.10618. arxiv:2011.10618Google Scholar
- Per Martin-Löf. 1984. Intuitionistic Type Theory. Bibliopolis, Napoli.Google Scholar
- Max S. New and Amal Ahmed. 2018. Graduality from Embedding-Projection Pairs. Proc. ACM Program. Lang., 2, ICFP (2018), 73:1–73:30. https://doi.org/10.1145/3236768 Google Scholar
Digital Library
- Max S. New and Daniel R. Licata. 2020. Call-by-name Gradual Type Theory. Logical Methods in Computer Science, Volume 16, Issue 1 (2020), Jan., https://doi.org/10.23638/LMCS-16(1:7)2020 Google Scholar
Cross Ref
- Susumu Nishimura. 1998. Static Typing for Dynamic Messages. In Proc. 25th ACM Symp. POPL, Luca Cardelli (Ed.). ACM Press, San Diego, CA, USA. 266–278. isbn:0-89791-979-3 https://doi.org/10.1145/268946.268968 Google Scholar
Digital Library
- Ulf Norell. 2008. Dependently Typed Programming in Agda. In Advanced Functional Programming, Pieter W. M. Koopman, Rinus Plasmeijer, and S. Doaitse Swierstra (Eds.) (LNCS, Vol. 5832). Springer, Heijen, The Netherlands. 230–266. isbn:978-3-642-04651-3Google Scholar
- Xinming Ou, Gang Tan, Yitzhak Mandelbaum, and David Walker. 2004. Dynamic Typing with Dependent Types. In IFIP TCS, Jean-Jacques Lévy, Ernst W. Mayr, and John C. Mitchell (Eds.). Kluwer, 437–450. isbn:1-4020-8140-5Google Scholar
- Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM TOPLAS, 22, 1 (2000), 1–44. issn:0164-0925 https://doi.org/10.1145/345099.345100 Google Scholar
Digital Library
- Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2014. A theory of gradual effect systems. In Proceedings of the 19th ACM SIGPLAN international conference on Functional programming, Gothenburg, Sweden, September 1-3, 2014, Johan Jeuring and Manuel M. T. Chakravarty (Eds.). ACM, Gothenburg, Sweden. 283–295. isbn:978-1-4503-2873-9 https://doi.org/10.1145/2628136.2628149 Google Scholar
Digital Library
- Jeremy Siek and Walid Taha. 2007. Gradual Typing for Objects. In 21st ECOOP, Erik Ernst (Ed.) (LNCS, Vol. 4609). Springer, Berlin, Germany. 2–27. isbn:978-3-540-73588-5 https://doi.org/10.1007/978-3-540-73589-2_2 Google Scholar
Digital Library
- Jeremy Siek, Peter Thiemann, and Philip Wadler. 2015. Blame and Coercion: Together Again for the First Time. In PLDI, Steve Blackburn (Ed.). ACM, Portland, OR, USA. 425–435. isbn:978-1-4503-3468-6 https://doi.org/10.1145/2737924.2737968 Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. 2006. Gradual Typing for Functional Languages. In Scheme and Functional Programming Workshop.Google Scholar
- Jeremy G. Siek and Manish Vachharajani. 2008. Gradual Typing with Unification-Based Inference. In Proceedings of the 2008 Symposium on Dynamic Languages, DLS 2008, July 8, 2008, Paphos, Cyprus, Johan Brichau (Ed.). ACM, 7. https://doi.org/10.1145/1408681.1408688 Google Scholar
Digital Library
- Jeremy G. Siek, Michael M. Vitousek, Matteo Cimini, and John Tang Boyland. 2015. Refined Criteria for Gradual Typing. In SNAPL (LIPIcs, Vol. 32). Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 274–293.Google Scholar
- Jeremy G. Siek and Philip Wadler. 2010. Threesomes, With and Without Blame. In Proc. 37th ACM Symp. POPL. ACM Press, Madrid, Spain. 365–376. isbn:978-1-60558-479-9 https://doi.org/10.1145/1706299.1706342 Google Scholar
Digital Library
- Vilhelm Sjöberg, Chris Casinghino, Ki Yung Ahn, Nathan Collins, Harley D. Eades III, Peng Fu, Garrin Kimmell, Tim Sheard, Aaron Stump, and Stephanie Weirich. 2012. Irrelevance, Heterogeneous Equality, and Call-by-value Dependent Type Systems. In Proceedings Fourth Workshop on Mathematically Structured Functional Programming, James Chapman and Paul Blain Levy (Eds.) (EPTCS, Vol. 76). Tallinn, Estonia. 112–162. https://doi.org/10.4204/EPTCS.76.9 Google Scholar
Cross Ref
- Christopher Stone. 2000. Singleton Kinds and Singleton Types. Ph.D. Dissertation. School of Computer Science, CMU.Google Scholar
- Christopher A. Stone and Robert Harper. 2006. Extensional Equivalence and Singleton Types. ACM Trans. Comput. Log., 7, 4 (2006), 676–722. https://doi.org/10.1145/1183278.1183281 Google Scholar
Digital Library
- Nikhil Swamy, Juan Chen, Cédric Fournet, Pierre-Yves Strub, Karthikeyan Bhargavan, and Jean Yang. 2013. Secure Distributed Programming With Value-Dependent Types. J. Funct. Program., 23, 4 (2013), 402–451. https://doi.org/10.1017/S0956796813000142 Google Scholar
Cross Ref
- Nikhil Swamy, Cédric Fournet, Aseem Rastogi, Karthikeyan Bhargavan, Juan Chen, Pierre-Yves Strub, and Gavin M. Bierman. 2014. Gradual Typing Embedded Securely in JavaScript. In POPL. ACM, 425–438.Google Scholar
- Éric Tanter and Nicolas Tabareau. 2015. Gradual Certified Programming in Coq. In Proceedings of the 11th Symposium on Dynamic Languages, DLS 2015, part of SPLASH 2015, Pittsburgh, PA, USA, October 25-30, 2015, Manuel Serrano (Ed.). ACM, 26–40. https://doi.org/10.1145/2816707.2816710 Google Scholar
Digital Library
- Peter Thiemann and Vasco T. Vasconcelos. 2020. Label-Dependent Session Types. Proc. ACM Program. Lang., 4, POPL (2020), 67:1–67:29. https://doi.org/10.1145/3371135 Google Scholar
Digital Library
- Matías Toro, Ronald Garcia, and Éric Tanter. 2018. Type-Driven Gradual Security with References. ACM Trans. Program. Lang. Syst., 40, 4 (2018), 16:1–16:55. https://doi.org/10.1145/3229061 Google Scholar
Digital Library
- 2021. TypeScript Handbook, Advanced Types. https://www.typescriptlang.org/docs/handbook/advanced-types.htmlGoogle Scholar
- Philip Wadler and Robert Bruce Findler. 2009. Well-Typed Programs Can’t Be Blamed. In Programming Languages and Systems, 18th European Symposium on Programming, ESOP 2009, Giuseppe Castagna (Ed.) (Lecture Notes in Computer Science, Vol. 5502). Springer, York, UK. 1–16. isbn:978-3-642-00589-3 https://doi.org/10.1007/978-3-642-00590-9 Google Scholar
Cross Ref
- Stephanie Weirich, Pritam Choudhury, Antoine Voizard, and Richard A. Eisenberg. 2019. A Role for Dependent Types in Haskell. Proc. ACM Program. Lang., 3, ICFP (2019), 101:1–101:29. https://doi.org/10.1145/3341705 Google Scholar
Digital Library
- Hongwei Xi and Frank Pfenning. 1999. Dependent Types in Practical Programming. In Proc. 26th ACM Symp. POPL, Alexander Aiken (Ed.). ACM Press, San Antonio, Texas, USA. 214–227. isbn:1-58113-095-3Google Scholar
Digital Library
Index Terms
Label dependent lambda calculus and gradual typing
Recommendations
Gradual typing: a new perspective
We define a new, more semantic interpretation of gradual types and use it to ``gradualize'' two forms of polymorphism: subtyping polymorphism and implicit parametric polymorphism. In particular, we use the new interpretation to define three gradual type ...
Unifying typing and subtyping
In recent years dependent types have become a hot topic in programming language research. A key reason why dependent types are interesting is that they allow unifying types and terms, which enables both additional expressiveness and economy of concepts. ...
The Blame Theorem for a Linear Lambda Calculus with Type Dynamic
TFP 2012: Proceedings of the 2012 Conference on Trends in Functional Programming - Volume 7829Scripting languages have renewed the interest in languages with dynamic types. For various reasons, realistic programs comprise dynamically typed components as well as statically typed ones. Safe and seamless interaction between these components is ...






Comments