Julia’s Efficient Algorithm for Subtyping Unions and Covariant Tuples (Pearl)

Authors Benjamin Chung, Francesco Zappa Nardelli, Jan Vitek



PDF
Thumbnail PDF

File

LIPIcs.ECOOP.2019.24.pdf
  • Filesize: 0.58 MB
  • 15 pages

Document Identifiers

Author Details

Benjamin Chung
  • Northeastern University, Boston, MA, USA
Francesco Zappa Nardelli
  • Inria of Paris, Paris, France
Jan Vitek
  • Northeastern University, Boston, MA, USA
  • Czech Technical University in Prague, Czech Republic

Acknowledgements

The authors thank Jiahao Chen for starting us down the path of understanding Julia, and Jeff Bezanson for coming up with Julia’s subtyping algorithm. We would also like to thank Ming-Ho Yee, Celeste Hollenbeck, and Julia Belyakova for their help in preparing this paper. This work received funding from the European Research Council under the European Union’s Horizon 2020 research and innovation programme (grant agreement 695412), the NSF (award 1544542 and award 1518844), the ONR (grant 503353), and the Czech Ministry of Education, Youth and Sports (grant agreement CZ.02.1.01/0.0/0.0/15_003/0000421).

Cite AsGet BibTex

Benjamin Chung, Francesco Zappa Nardelli, and Jan Vitek. Julia’s Efficient Algorithm for Subtyping Unions and Covariant Tuples (Pearl). In 33rd European Conference on Object-Oriented Programming (ECOOP 2019). Leibniz International Proceedings in Informatics (LIPIcs), Volume 134, pp. 24:1-24:15, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2019)
https://doi.org/10.4230/LIPIcs.ECOOP.2019.24

Abstract

The Julia programming language supports multiple dispatch and provides a rich type annotation language to specify method applicability. When multiple methods are applicable for a given call, Julia relies on subtyping between method signatures to pick the correct method to invoke. Julia’s subtyping algorithm is surprisingly complex, and determining whether it is correct remains an open question. In this paper, we focus on one piece of this problem: the interaction between union types and covariant tuples. Previous work normalized unions inside tuples to disjunctive normal form. However, this strategy has two drawbacks: complex type signatures induce space explosion, and interference between normalization and other features of Julia’s type system. In this paper, we describe the algorithm that Julia uses to compute subtyping between tuples and unions - an algorithm that is immune to space explosion and plays well with other features of the language. We prove this algorithm correct and complete against a semantic-subtyping denotational model in Coq.

Subject Classification

ACM Subject Classification
  • Theory of computation → Type theory
Keywords
  • Type systems
  • Subtyping
  • Union types

Metrics

  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    0
    PDF Downloads

References

  1. Alexander Aiken and Brian R. Murphy. Implementing regular tree expressions. In Functional Programming Languages and Computer Architecture FPCA, 1991. URL: http://dx.doi.org/10.1007/3540543961_21.
  2. Franco Barbanera and Mariangiola Dezani-Ciancaglini. Intersection and union types. In Theoretical Aspects of Computer Software TACS, 1991. URL: http://dx.doi.org/10.1007/3-540-54415-1_69.
  3. Julia Belyakova. Decidable Tag-Based Semantic Subtyping for Nominal Types, Tuples, and Unions. In Proceedings of the 21st Workshop on Formal Techniques for Java-like Programs FTFJP, 2019. Google Scholar
  4. Jeff Bezanson. Abstraction in technical computing. PhD thesis, Massachusetts Institute of Technology, 2015. URL: http://dspace.mit.edu/handle/1721.1/7582.
  5. Jeff Bezanson, Alan Edelman, Stefan Karpinski, and Viral B. Shah. Julia: A Fresh Approach to Numerical Computing. SIAM Review, 59(1), 2017. URL: http://dx.doi.org/10.1137/141000671.
  6. Flemming M. Damm. Subtyping with Union Types, Intersection Types and Recursive Types. In Theoretical Aspects of Computer Software TACS, 1994. URL: http://dx.doi.org/10.1007/3-540-57887-0_121.
  7. Joshua Dunfield. Elaborating intersection and union types. J. Funct. Program., 2014. URL: http://dx.doi.org/10.1017/S0956796813000270.
  8. Facebook. Hack. URL: https://hacklang.org/.
  9. Alain Frisch, Giuseppe Castagna, and Véronique Benzaken. Semantic subtyping: Dealing set-theoretically with function, union, intersection, and negation types. J. ACM, 55(4), 2008. URL: http://dx.doi.org/10.1145/1391289.1391293.
  10. Haruo Hosoya, Jérôme Vouillon, and Benjamin C. Pierce. Regular Expression Types for XML. ACM Trans. Program. Lang. Syst., 2005. Google Scholar
  11. Microsoft. Typescript Language Specification. URL: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md.
  12. Fabian Muehlboeck and Ross Tate. Empowering Union and Intersection Types with Integrated Subtyping. Proc. ACM Program. Lang., 2(OOPSLA), 2018. Google Scholar
  13. David J. Pearce. Sound and Complete Flow Typing with Unions, Intersections and Negations. In Verification, Model Checking, and Abstract Interpretation VMCAI, 2013. URL: http://dx.doi.org/10.1007/978-3-642-35873-9_21.
  14. Benjamin Pierce. Programming with intersection types, union types, and polymorphism. Technical Report CMU-CS-91-106, Carnegie Mellon University, 1991. Google Scholar
  15. Ross Tate. personal communication. Google Scholar
  16. Jerome Vouillon. Subtyping Union Types. In Computer Science Logic (CSL), 2004. URL: http://dx.doi.org/10.1007/978-3-540-30124-0_32.
  17. Francesco Zappa Nardelli, Julia Belyakova, Artem Pelenitsyn, Benjamin Chung, Jeff Bezanson, and Jan Vitek. Julia subtyping: a rational reconstruction. Proc. ACM Program. Lang., 2(OOPSLA), 2018. URL: http://dx.doi.org/10.1145/3276483.
Questions / Remarks / Feedback
X

Feedback for Dagstuhl Publishing


Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail