skip to main content
research-article
Open Access

Coeffects for sharing and mutation

Published:31 October 2022Publication History
Skip Abstract Section

Abstract

In type-and-coeffect systems, contexts are enriched by coeffects modeling how they are actually used, typically through annotations on single variables. Coeffects are computed bottom-up, combining, for each term, the coeffects of its subterms, through a fixed set of algebraic operators. We show that this principled approach can be adopted to track sharing in the imperative paradigm, that is, links among variables possibly introduced by the execution. This provides a significant example of non-structural coeffects, which cannot be computed by-variable, since the way a given variable is used can affect the coeffects of other variables. To illustrate the effectiveness of the approach, we enhance the type system tracking sharing to model a sophisticated set of features related to uniqueness and immutability. Thanks to the coeffect-based approach, we can express such features in a simple way and prove related properties with standard techniques.

References

  1. Andreas Abel and Jean-Philippe Bernardy. 2020. A unified view of modalities in type systems. Proceedings of ACM on Programming Languages, 4, ICFP (2020), 90:1–90:28. https://doi.org/10.1145/3408972 Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Paulo Sérgio Almeida. 1997. Balloon Types: Controlling Sharing of State in Data Types. In European Conference on Object-Oriented Programming, ECOOP 1997 (Lecture Notes in Computer Science, Vol. 1241). Springer, 32–59. Google ScholarGoogle Scholar
  3. Robert Atkey. 2018. Syntax and Semantics of Quantitative Type Theory. In IEEE Symposium on Logic in Computer Science, LICS 2018, Anuj Dawar and Erich Grädel (Eds.). ACM Press, 56–65. https://doi.org/10.1145/3209108.3209189 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Riccardo Bianchini, Francesco Dagnino, Paola Giannini, and Elena Zucca. 2022. A Java-like calculus with user-defined coeffects. In ICTCS’22 - Italian Conf. on Theoretical Computer Science. To appear Google ScholarGoogle Scholar
  5. Riccardo Bianchini, Francesco Dagnino, Paola Giannini, Elena Zucca, and Marco Servetto. 2022. Coeffects for sharing and mutation. CoRR, abs/2209.07439 (2022), https://doi.org/10.48550/arXiv.2209.07439 Google ScholarGoogle Scholar
  6. John Boyland. 2010. Semantics of Fractional Permissions with Nesting. ACM Transactions on Programming Languages and Systems, 32, 6 (2010). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Flavien Breuvart and Michele Pagani. 2015. Modelling Coeffects in the Relational Semantics of Linear Logic. In 24th EACSL Annual Conference on Computer Science Logic, CSL 2015, Stephan Kreutzer (Ed.) (LIPIcs, Vol. 41). Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 567–581. https://doi.org/10.4230/LIPIcs.CSL.2015.567 Google ScholarGoogle ScholarCross RefCross Ref
  8. Aloïs Brunel, Marco Gaboardi, Damiano Mazza, and Steve Zdancewic. 2014. A Core Quantitative Coeffect Calculus. In European Symposium on Programming, ESOP 2013, Zhong Shao (Ed.) (Lecture Notes in Computer Science, Vol. 8410). Springer, 351–370. https://doi.org/10.1007/978-3-642-54833-8_19 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Elias Castegren and Tobias Wrigstad. 2016. Reference Capabilities for Concurrency Control. In European Conference on Object-Oriented Programming, ECOOP 2016, Shriram Krishnamurthi and Benjamin S. Lerner (Eds.) (LIPIcs, Vol. 56). Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 5:1–5:26. Google ScholarGoogle Scholar
  10. Pritam Choudhury, Harley Eades III, Richard A. Eisenberg, and Stephanie Weirich. 2021. A graded dependent type system with a usage-aware semantics. Proceedings of ACM on Programming Languages, 5, POPL (2021), 1–32. https://doi.org/10.1145/3434331 Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. David Clarke and Tobias Wrigstad. 2003. External Uniqueness is Unique Enough. In European Conference on Object-Oriented Programming, ECOOP 2003, Luca Cardelli (Ed.) (Lecture Notes in Computer Science, Vol. 2473). Springer, 176–200. Google ScholarGoogle ScholarCross RefCross Ref
  12. Sylvan Clebsch. 2017. ’Pony’: co-designing a type system and a runtime. Ph. D. Dissertation. Imperial College London, UK. https://ethos.bl.uk/OrderDetails.do?uin=uk.bl.ethos.769552 Google ScholarGoogle Scholar
  13. Sylvan Clebsch, Sophia Drossopoulou, Sebastian Blessing, and Andy McNeil. 2015. Deny capabilities for safe, fast actors. In International Workshop on Programming Based on Actors, Agents, and Decentralized Control, AGERE! 2015, Elisa Gonzalez Boix, Philipp Haller, Alessandro Ricci, and Carlos Varela (Eds.). ACM Press, 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Ugo Dal Lago and Francesco Gavazzo. 2022. A relational theory of effects and coeffects. Proceedings of ACM on Programming Languages, 6, POPL (2022), 1–28. https://doi.org/10.1145/3498692 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Werner Dietl, Sophia Drossopoulou, and Peter Müller. 2007. Generic Universe Types. In European Conference on Object-Oriented Programming, ECOOP 2007, Erik Ernst (Ed.) (Lecture Notes in Computer Science, Vol. 4609). Springer, 28–53. Google ScholarGoogle Scholar
  16. Marco Gaboardi, Shin-ya Katsumata, Dominic A. Orchard, Flavien Breuvart, and Tarmo Uustalu. 2016. Combining effects and coeffects via grading. In ACM International Conference on Functional Programming, ICFP 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM Press, 476–489. https://doi.org/10.1145/2951913.2951939 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Dan R. Ghica and Alex I. Smith. 2014. Bounded Linear Types in a Resource Semiring. In European Symposium on Programming, ESOP 2013, Zhong Shao (Ed.) (Lecture Notes in Computer Science, Vol. 8410). Springer, 331–350. https://doi.org/10.1007/978-3-642-54833-8_18 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Paola Giannini, Tim Richter, Marco Servetto, and Elena Zucca. 2019. Tracing sharing in an imperative pure calculus. Science of Computer Programming, 172 (2019), 180–202. https://doi.org/10.1016/j.scico.2018.11.007 Extended version, CoRR. Google ScholarGoogle ScholarCross RefCross Ref
  19. Paola Giannini, Marco Servetto, Elena Zucca, and James Cone. 2019. Flexible recovery of uniqueness and immutability. Theoretical Computer Science, 764 (2019), 145–172. https://doi.org/10.1016/j.tcs.2018.09.001 Extended version, CoRR. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Colin S. Gordon. 2020. Designing with Static Capabilities and Effects: Use, Mention, and Invariants (Pearl). In European Conference on Object-Oriented Programming, ECOOP 2020, Robert Hirschfeld and Tobias Pape (Eds.) (LIPIcs, Vol. 166). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 10:1–10:25. https://doi.org/10.4230/LIPIcs.ECOOP.2020.10 Google ScholarGoogle ScholarCross RefCross Ref
  21. Colin S. Gordon, Matthew J. Parkinson, Jared Parsons, Aleks Bromfield, and Joe Duffy. 2012. Uniqueness and reference immutability for safe parallelism. In ACM Symp. on Object-Oriented Programming: Systems, Languages and Applications 2012, Gary T. Leavens and Matthew B. Dwyer (Eds.). ACM Press, 21–40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Philipp Haller and Martin Odersky. 2010. Capabilities for uniqueness and borrowing. In European Conference on Object-Oriented Programming, ECOOP 2010, Theo D’Hondt (Ed.) (Lecture Notes in Computer Science, Vol. 6183). Springer, 354–378. Google ScholarGoogle ScholarCross RefCross Ref
  23. John Hogg. 1991. Islands: Aliasing Protection in Object-oriented Languages. In ACM Symp. on Object-Oriented Programming: Systems, Languages and Applications 1991, Andreas Paepcke (Ed.). ACM Press, 271–285. Google ScholarGoogle Scholar
  24. Atsushi Igarashi, Benjamin C. Pierce, and Philip Wadler. 1999. Featherweight Java: A Minimal Core Calculus for Java and GJ. In ACM Symp. on Object-Oriented Programming: Systems, Languages and Applications 1999. ACM Press, 132–146. https://doi.org/10.1145/320384.320395 Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: securing the foundations of the rust programming language. Proceedings of ACM on Programming Languages, 2, POPL (2018), 66:1–66:34. https://doi.org/10.1145/3158154 Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Daniel Marshall, Michael Vollmer, and Dominic Orchard. 2022. Linearity and Uniqueness: An Entente Cordiale. In European Symposium on Programming, ESOP 2022, Ilya Sergey (Ed.) (Lecture Notes in Computer Science, Vol. 13240). Springer, 346–375. https://doi.org/10.1007/978-3-030-99336-8_13 Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Conor McBride. 2016. I Got Plenty o’ Nuttin’. In A List of Successes That Can Change the World - Essays Dedicated to Philip Wadler on the Occasion of His 60th Birthday, Sam Lindley, Conor McBride, Philip W. Trinder, and Donald Sannella (Eds.) (Lecture Notes in Computer Science, Vol. 9600). Springer, 207–233. https://doi.org/10.1007/978-3-319-30936-1_12 Google ScholarGoogle ScholarCross RefCross Ref
  28. Mae Milano, Andrew C. Meyers, and Joshua Turcotti. 2022. A Flexible Type System for Fearless Concurrency. To appear Google ScholarGoogle Scholar
  29. Peter Müller and Arsenii Rudich. 2007. Ownership transfer in universe types. In ACM Symp. on Object-Oriented Programming: Systems, Languages and Applications 2007, Richard P. Gabriel, David F. Bacon, Cristina Videira Lopes, and Guy L. Steele Jr. (Eds.). ACM Press, 461–478. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Dominic Orchard, Vilem-Benjamin Liepelt, and Harley Eades III. 2019. Quantitative program reasoning with graded modal types. Proceedings of ACM on Programming Languages, 3, ICFP (2019), 110:1–110:30. https://doi.org/10.1145/3341714 Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Tomas Petricek, Dominic A. Orchard, and Alan Mycroft. 2013. Coeffects: Unified Static Analysis of Context-Dependence. In Automata, Languages and Programming, ICALP 2013, Fedor V. Fomin, Rusins Freivalds, Marta Z. Kwiatkowska, and David Peleg (Eds.) (Lecture Notes in Computer Science, Vol. 7966). Springer, 385–397. https://doi.org/10.1007/978-3-642-39212-2_35 Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Tomas Petricek, Dominic A. Orchard, and Alan Mycroft. 2014. Coeffects: a calculus of context-dependent computation. In ACM International Conference on Functional Programming, ICFP 2014, Johan Jeuring and Manuel M. T. Chakravarty (Eds.). ACM Press, 123–135. https://doi.org/10.1145/2628136.2628160 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Marco Servetto, David J. Pearce, Lindsay Groves, and Alex Potanin. 2013. Balloon Types for Safe Parallelisation over Arbitrary Object Graphs. In WODET 2014 - Workshop on Determinism and Correctness in Parallel Programming. Google ScholarGoogle Scholar
  34. James Wood and Robert Atkey. 2022. A Framework for Substructural Type Systems. In European Symposium on Programming, ESOP 2022, Ilya Sergey (Ed.) (Lecture Notes in Computer Science, Vol. 13240). Springer, 376–402. https://doi.org/10.1007/978-3-030-99336-8_14 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Coeffects for sharing and mutation

      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

      • Published in

        cover image Proceedings of the ACM on Programming Languages
        Proceedings of the ACM on Programming Languages  Volume 6, Issue OOPSLA2
        October 2022
        1932 pages
        EISSN:2475-1421
        DOI:10.1145/3554307
        Issue’s Table of Contents

        Copyright © 2022 Owner/Author

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 31 October 2022
        Published in pacmpl Volume 6, Issue OOPSLA2

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article
      • Article Metrics

        • Downloads (Last 12 months)165
        • Downloads (Last 6 weeks)17

        Other Metrics

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!