skip to main content

On type-cases, union elimination, and occurrence typing

Published:12 January 2022Publication History
Skip Abstract Section

Abstract

We extend classic union and intersection type systems with a type-case construction and show that the combination of the union elimination rule of the former and the typing rules for type-cases of our extension encompasses occurrence typing. To apply this system in practice, we define a canonical form for the expressions of our extension, called MSC-form. We show that an expression of the extension is typable if and only if its MSC-form is, and reduce the problem of typing the latter to the one of reconstructing annotations for that term. We provide a sound algorithm that performs this reconstruction and a proof-of-concept implementation.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

Short video presentation of the article

References

  1. Franco Barbanera, Mariangiola Dezani-Ciancaglini, and Ugo de’Liguoro. 1995. Intersection and Union Types. Inf. Comput., 119, 2 (1995), June, 202–230. issn:0890-5401 https://doi.org/10.1006/inco.1995.1086 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Giuseppe Castagna. 2020. Covariance and Controvariance: a fresh look at an old issue (a primer in advanced type systems for learning functional programmers). Logical Methods in Computer Science, 16, 1 (2020), 15:1–15:58. https://doi.org/10.23638/LMCS-16(1:15)2020 Google ScholarGoogle ScholarCross RefCross Ref
  3. Giuseppe Castagna and Victor Lanvin. 2017. Gradual Typing with Union and Intersection Types. Proc. ACM Program. Lang., 1, ICFP (2017), Article 41, Aug., 28 pages. issn:2475-1421 https://doi.org/10.1145/3110285 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Giuseppe Castagna, Victor Lanvin, Mickaël Laurent, and Kim Nguyễn. 2021. Revisiting Occurrence Typing. oct, arXiv:1907.05590. To appear in Science of Computer Programming, ElsevierGoogle ScholarGoogle Scholar
  5. Giuseppe Castagna, Victor Lanvin, Tommaso Petrucciani, and Jeremy G. Siek. 2019. Gradual Typing: a New Perspective. Proc. ACM Program. Lang., 3, POPL ’19 46th ACM Symposium on Principles of Programming Languages (2019), Article 16, Jan., 32 pages. https://doi.org/10.1145/3290329 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Giuseppe Castagna, Mickaël Laurent, Kim Nguyễn, and Matthew Lutze. 2022. Prototype for Article: On Type-Cases, Union Elimination, and Occurrence Typing. https://doi.org/10.1145/3462306 Online interactive version available at Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Giuseppe Castagna, Kim Nguyễn, Zhiwu Xu, and Pietro Abate. 2015. Polymorphic functions with set-theoretic types. Part 2: local type inference and type reconstruction. In Proceedings of the 42nd Annual ACM SIGPLAN Symposium on Principles of Programming Languages (POPL ’15). 289–302. https://doi.org/10.1145/2676726.2676991 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Giuseppe Castagna, Kim Nguyễn, Zhiwu Xu, Hyeonseung Im, Sergueï Lenglet, and Luca Padovani. 2014. Polymorphic Functions with Set-Theoretic Types. Part 1: Syntax, Semantics, and Evaluation. In Proceedings of the 41st Annual ACM SIGPLAN Symposium on Principles of Programming Languages (POPL ’14). 5–17. https://doi.org/10.1145/2676726.2676991 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Giuseppe Castagna, Tommaso Petrucciani, and Kim Nguyễn. 2016. Set-Theoretic Types for Polymorphic Variants. In ICFP ’16, 21st ACM SIGPLAN International Conference on Functional Programming. 378–391. https://doi.org/10.1145/2951913.2951928 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Giuseppe Castagna and Zhiwu Xu. 2011. Set-theoretic Foundation of Parametric Polymorphism and Subtyping. In ICFP ’11: 16th ACM-SIGPLAN International Conference on Functional Programming. 94–106. https://doi.org/10.1145/2034773.2034788 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. The CDuce Compiler. https://www.cduce.orgGoogle ScholarGoogle Scholar
  12. Arthur Charguéraud. 2012. The Locally Nameless Representation. J. Autom. Reason., 49, 3 (2012), 363–408. https://doi.org/10.1007/s10817-011-9225-2 Google ScholarGoogle ScholarCross RefCross Ref
  13. Avik Chaudhuri, Panagiotis Vekris, Sam Goldman, Marshall Roch, and Gabriel Levi. 2017. Fast and Precise Type Checking for JavaScript. Proc. ACM Program. Lang., 1, OOPSLA (2017), Article 48, Oct., 30 pages. issn:2475-1421 https://doi.org/10.1145/3133872 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Mariangiola Dezani-Ciancaglini. 2020. Personal communicationGoogle ScholarGoogle Scholar
  15. Mariangiola Dezani-Ciancaglini, Alain Frisch, Elio Giovannetti, and Yoko Motohama. 2003. The Relevance of Semantic Subtyping. Electronic Notes in Theoretical Computer Science, 70, 1 (2003), 88 – 105. issn:1571-0661 https://doi.org/10.1016/S1571-0661(04)80492-4 ITRS ’02, Intersection Types and Related Systems (FLoC Satellite Event) Google ScholarGoogle ScholarCross RefCross Ref
  16. Jana Dunfield and Neel Krishnaswami. 2019. Bidirectional Typing. CoRR, abs/1908.05839 (2019), arxiv:1908.05839.Google ScholarGoogle Scholar
  17. Jana Dunfield and Neelakantan R. Krishnaswami. 2019. Sound and Complete Bidirectional Typechecking for Higher-Rank Polymorphism with Existentials and Indexed Types. Proc. ACM Program. Lang., 3, POPL (2019), Article 9, Jan., 28 pages. https://doi.org/10.1145/3290322 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Flow. https://flow.org/Google ScholarGoogle Scholar
  19. Alain Frisch. 2004. Théorie, conception et réalisation d’un langage de programmation adapté à XML. Ph. D. Dissertation. Université Paris Diderot. http://www.cduce.org/papers/frisch_phd.pdfGoogle ScholarGoogle Scholar
  20. Alain Frisch, Giuseppe Castagna, and Véronique Benzaken. 2002. Semantic Subtyping. In LICS ’02, 17th Annual IEEE Symposium on Logic in Computer Science. IEEE Computer Society Press, 137–146. https://doi.org/10.1109/LICS.2002.1029823 Google ScholarGoogle ScholarCross RefCross Ref
  21. Alain Frisch, Giuseppe Castagna, and Véronique Benzaken. 2008. Semantic subtyping: dealing set-theoretically with function, union, intersection, and negation types. Journal of the ACM, 55, 4 (2008), Sept., 19:1–19:64. issn:0004-5411 http://doi.acm.org/10.1145/1391289.1391293 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. Roger Hindley and Jonathan P. Seldin. 2008. Lambda-Calculus and Combinators An Introduction. Cambridge University Press. isbn:978-0-521-89885-0Google ScholarGoogle Scholar
  23. Andrew M. Kent. 2019. Advanced Logical Type Systems for Untyped Languages. Ph. D. Dissertation. Indiana University. https://pnwamk.github.io/docs/dissertation.pdfGoogle ScholarGoogle Scholar
  24. David MacQueen, Gordon Plotkin, and Ravi Sethi. 1986. An ideal model for recursive polymorphic types. Information and Control, 71, 1 (1986), 95–130. issn:0019-9958 https://doi.org/10.1016/S0019-9958(86)80019-5 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Per Martin-Löf. 1994. Analytic and Synthetic Judgements in Type Theory. Springer Netherlands, Dordrecht. 87–99. isbn:978-94-011-0834-8 https://doi.org/10.1007/978-94-011-0834-8_5 Google ScholarGoogle ScholarCross RefCross Ref
  26. TypeScript. https://www.typescriptlang.org/Google ScholarGoogle Scholar
  27. Tommaso Petrucciani. 2019. Polymorphic Set-Theoretic Types for Functional Languages. Ph. D. Dissertation. Joint Ph.D. Thesis, Università di Genova and Université Paris Diderot. https://tel.archives-ouvertes.fr/tel-02119930Google ScholarGoogle Scholar
  28. Benjamin C. Pierce and David N. Turner. 2000. Local Type Inference. ACM Trans. Program. Lang. Syst., 22, 1 (2000), Jan., 1–44. issn:0164-0925 https://doi.org/10.1145/345099.345100 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. François Pottier and Yann Régis-Gianas. 2006. Stratified type inference for generalized algebraic data types. In Proceedings of the 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2006, Charleston, South Carolina, USA, January 11-13, 2006, J. Gregory Morrisett and Simon L. Peyton Jones (Eds.). ACM, 232–244. https://doi.org/10.1145/1111037.1111058 Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Aseem Rastogi, Nikhil Swamy, Cédric Fournet, Gavin Bierman, and Panagiotis Vekris. 2015. Safe and Efficient Gradual Typing for TypeScript. In Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’15). Association for Computing Machinery, New York, NY, USA. 167–180. isbn:9781450333009 https://doi.org/10.1145/2676726.2676971 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Patrick Maxim Rondon, Ming Kawaguchi, and Ranjit Jhala. 2008. Liquid types. In Proceedings of the ACM SIGPLAN 2008 Conference on Programming Language Design and Implementation, Tucson, AZ, USA, June 7-13, 2008, Rajiv Gupta and Saman P. Amarasinghe (Eds.). ACM, 159–169. https://doi.org/10.1145/1375581.1375602 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Amr Sabry and Matthias Felleisen. 1992. Reasoning about Programs in Continuation-Passing Style.. In Proceedings of the 1992 ACM Conference on LISP and Functional Programming (LFP ’92). Association for Computing Machinery, 288–298. isbn:0897914813 https://doi.org/10.1145/141471.141563 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Sam Tobin-Hochstadt and Matthias Felleisen. 2008. The Design and Implementation of Typed Scheme. In Proceedings of the 35th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’08). ACM, New York, NY, USA. 395–406. isbn:978-1-59593-689-9 https://doi.org/10.1145/1328438.1328486 Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. Sam Tobin-Hochstadt and Matthias Felleisen. 2010. Logical types for untyped languages. In Proceedings of the 15th ACM SIGPLAN International Conference on Functional Programming (ICFP ’10). ACM, New York, NY, USA. 117–128. isbn:978-1-60558-794-3 https://doi.org/10.1145/1863543.1863561 Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. 2019. What exactly should we call syntax-directed inference rules? Discussion on the Types mailing list. http://lists.seas.upenn.edu/pipermail/types-list/2019/002138.htmlGoogle ScholarGoogle Scholar
  36. Wikipedia. 2021. Peter Parker principle. https://en.wikipedia.org/wiki/With_great_power_comes_great_responsibility [Online; accessed 22-October-2021]Google ScholarGoogle Scholar
  37. Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation, 115, 1 (1994), 38–94. issn:0890-5401 https://doi.org/10.1006/inco.1994.1093 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. On type-cases, union elimination, and occurrence typing

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader