Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article
Open access

Kindly bent to free us

Published: 03 August 2020 Publication History
  • Get Citation Alerts
  • Abstract

    Systems programming often requires the manipulation of resources like file handles, network connections, or dynamically allocated memory. Programmers need to follow certain protocols to handle these resources correctly. Violating these protocols causes bugs ranging from type mismatches over data races to use-after-free errors and memory leaks. These bugs often lead to security vulnerabilities.
    While statically typed programming languages guarantee type soundness and memory safety by design, most of them do not address issues arising from improper handling of resources. An important step towards handling resources is the adoption of linear and affine types that enforce single-threaded resource usage. However, the few languages supporting such types require heavy type annotations.
    We present Affe, an extension of ML that manages linearity and affinity properties using kinds and constrained types. In addition Affe supports the exclusive and shared borrowing of affine resources, inspired by features of Rust. Moreover, Affe retains the defining features of the ML family: it is an impure, strict, functional expression language with complete principal type inference and type abstraction. does not require any linearity annotations in expressions and supports common functional programming idioms.

    Supplementary Material

    Auxiliary Archive (icfp20main-p74-p-archive.zip)
    Additional examples, theoretical materials, and proofs.
    Presentation at ICFP '20 (a103-radanne-presentation.mp4)

    References

    [1]
    Peter Achten and Marinus J. Plasmeijer. 1995. The Ins and Outs of Clean I/O. J. Funct. Program. 5, 1 ( 1995 ), 81-110. https://doi.org/10.1017/S0956796800001258
    [2]
    Jonathan Aldrich, Joshua Sunshine, Darpan Saini, and Zachary Sparks. 2009. Typestate-oriented programming. In Companion to the 24th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2009, October 25-29, 2009, Orlando, Florida, USA, Shail Arora and Gary T. Leavens (Eds.). ACM, 1015-1022. https://doi.org/10.1145/1639950.1640073
    [3]
    Nada Amin and Tiark Rompf. 2017. Type Soundness Proofs With Definitional Interpreters. In POPL. ACM, 666-679.
    [4]
    Phil Bagwell. 2001. Ideal Hash Trees.
    [5]
    Thibaut Balabonski, François Pottier, and Jonathan Protzenko. 2016. The Design and Formalization of Mezzo, a PermissionBased Programming Language. ACM Trans. Program. Lang. Syst. 38, 4 ( 2016 ), 14 : 1-14 : 94. http://dl.acm.org/citation.cfm? id= 2837022
    [6]
    Erik Barendsen and Sjaak Smetsers. 1995. Uniqueness Type Inference. In Programming Languages: Implementations, Logics and Programs, 7th International Symposium, PLILP'95, Utrecht, The Netherlands, September 20-22, 1995, Proceedings (Lecture Notes in Computer Science, Vol. 982 ), Manuel V. Hermenegildo and S. Doaitse Swierstra (Eds.). Springer, 189-206. https://doi.org/10.1007/BFb0026821
    [7]
    Jean-Philippe Bernardy, Mathieu Boespflug, Ryan R. Newton, Simon Peyton Jones, and Arnaud Spiwack. 2018. Linear Haskell: Practical Linearity in a Higher-Order Polymorphic Language. PACMPL 2, POPL ( 2018 ), 5 : 1-5 : 29. https: //doi.org/10.1145/3158093
    [8]
    John Tang Boyland and William Retert. 2005. Connecting Efects and Uniqueness with Adoption. In Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2005, Long Beach, California, USA, January 12-14, 2005, Jens Palsberg and Martín Abadi (Eds.). ACM, 283-295. https://doi.org/10.1145/1040305.1040329
    [9]
    Sylvain Conchon and Jean-Christophe Filliâtre. 2007. A Persistent Union-Find Data Structure. In Proceedings of the ACM Workshop on ML, 2007, Freiburg, Germany, October 5, 2007, Claudio V. Russo and Derek Dreyer (Eds.). ACM, 37-46. https://doi.org/10.1145/1292535.1292541
    [10]
    Robert DeLine and Manuel Fähndrich. 2001. Enforcing High-Level Protocols in Low-Level Software. In PLDI. ACM, 59-69.
    [11]
    Stephen Dolan, Spiros Eliopoulos, Daniel Hillerström, Anil Madhavapeddy, K. C. Sivaramakrishnan, and Leo White. 2017. Concurrent System Programming with Efect Handlers. In Trends in Functional Programming-18th International Symposium, TFP 2017, Canterbury, UK, June 19-21, 2017, Revised Selected Papers (Lecture Notes in Computer Science, Vol. 10788 ), Meng Wang and Scott Owens (Eds.). Springer, 98-117. https://doi.org/10.1007/978-3-319-89719-6_6
    [12]
    Ronald Garcia, Éric Tanter, Roger Wolf, and Jonathan Aldrich. 2014. Foundations of Typestate-Oriented Programming. ACM Trans. Program. Lang. Syst. 36, 4 ( 2014 ), 12 : 1-12 : 44. https://doi.org/10.1145/2629609
    [13]
    Simon J. Gay and Vasco Thudichum Vasconcelos. 2010. Linear type theory for asynchronous session types. J. Funct. Program. 20, 1 ( 2010 ), 19-50. https://doi.org/10.1017/S0956796809990268
    [14]
    Jean-Yves Girard. 1987. Linear Logic. Theor. Comput. Sci. 50 ( 1987 ), 1-102. https://doi.org/10.1016/ 0304-3975 ( 87 ) 90045-4
    [15]
    Dan Grossman, J. Gregory Morrisett, Trevor Jim, Michael W. Hicks, Yanling Wang, and James Cheney. 2002. Region-Based Memory Management in Cyclone. In Proceedings of the 2002 ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Berlin, Germany, June 17-19, 2002, Jens Knoop and Laurie J. Hendren (Eds.). ACM, 282-293. https://doi.org/10.1145/512529.512563
    [16]
    Rich Hickey. 2017. clojure/PersistentHashMap.java. https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/ lang/PersistentHashMap.java
    [17]
    Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2018. RustBelt: Securing the Foundations of the Rust Programming Language. Proc. ACM Program. Lang. 2, POPL ( 2018 ), 66 : 1-66 : 34. https://doi.org/10.1145/3158154
    [18]
    Sam Lindley and J. Garrett Morris. 2017. Lightweight Functional Session Types. In Behavioral Types: From Theory to Tools, Simon Gay and António Ravara (Eds.). River Publishers.
    [19]
    Nicholas D. Matsakis and Felix S. Klock II. 2014. The Rust Language. In Proceedings of the 2014 ACM SIGAda annual conference on High integrity language technology, HILT 2014, Portland, Oregon, USA, October 18-21, 2014, Michael Feldman and S. Tucker Taft (Eds.). ACM, 103-104. https://doi.org/10.1145/2663171.2663188
    [20]
    Kazutaka Matsuda. 2019. A Modular Inference of Linear Types for Multiplicity-Annotated Arrows. CoRR abs/ 1911.00268 ( 2019 ). arXiv: 1911.00268 http://arxiv.org/abs/ 1911.00268
    [21]
    Karl Mazurak, Jianzhou Zhao, and Steve Zdancewic. 2010. Lightweight Linear Types in System F°. In Proceedings of TLDI 2010: 2010 ACM SIGPLAN International Workshop on Types in Languages Design and Implementation, Madrid, Spain, January 23, 2010, Andrew Kennedy and Nick Benton (Eds.). ACM, 77-88. https://doi.org/10.1145/1708016.1708027
    [22]
    J. Garrett Morris. 2016. The Best of Both Worlds: Linear Functional Programming Without Compromise. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming, ICFP 2016, Nara, Japan, September 18-22, 2016, Jacques Garrigue, Gabriele Keller, and Eijiro Sumii (Eds.). ACM, 448-461. https://doi.org/10.1145/2951913.2951925
    [23]
    Guillaume Munch-Maccagnoni. 2018. Resource Polymorphism. CoRR abs/ 1803.02796 ( 2018 ). arXiv: 1803.02796 http://arxiv.org/abs/ 1803.02796
    [24]
    Martin Odersky, Martin Sulzmann, and Martin Wehr. 1999. Type Inference with Constrained Types. TAPOS 5, 1 ( 1999 ), 35-55.
    [25]
    Martin Odersky, Philip Wadler, and Martin Wehr. 1995. A Second Look at Overloading. In Proceedings of the seventh international conference on Functional programming languages and computer architecture, FPCA 1995, La Jolla, California, USA, June 25-28, 1995, John Williams (Ed.). ACM, 135-146. https://doi.org/10.1145/224164.224195
    [26]
    Scott Owens, Magnus O. Myreen, Ramana Kumar, and Yong Kiam Tan. 2016. Functional Big-Step Semantics. In ESOP (Lecture Notes in Computer Science, Vol. 9632 ). Springer, 589-615.
    [27]
    Luca Padovani. 2017. A Simple Library Implementation of Binary Sessions. J. Funct. Program. 27 ( 2017 ), e4. https: //doi.org/10.1017/S0956796816000289
    [28]
    François Pottier and Vincent Simonet. 2002. Information Flow Inference for ML. In Conference Record of POPL 2002 : The 29th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Portland, OR, USA, January 16-18, 2002, John Launchbury and John C. Mitchell (Eds.). ACM, 319-330. https://doi.org/10.1145/503272.503302
    [29]
    Jonathan Protzenko. 2014. Mezzo: a typed language for safe efectful concurrent programs. (Mezzo: un langage typé pour programmer de manière concurrent et sure en présence d'efets). Ph.D. Dissertation. Paris Diderot University, France. https://tel.archives-ouvertes.fr/tel-01086106
    [30]
    Juan Pedro Bolívar Puente. 2017. Persistence for the Masses: RRB-Vectors in a Systems Language. PACMPL 1, ICFP ( 2017 ), 16 : 1-16 : 28. https://doi.org/10.1145/3110260
    [31]
    John C. Reynolds. 2002. Separation Logic: A Logic for Shared Mutable Data Structures. In 17th IEEE Symposium on Logic in Computer Science (LICS 2002 ), 22-25 July 2002, Copenhagen, Denmark, Proceedings. IEEE Computer Society, 55-74. https://doi.org/10.1109/LICS. 2002.1029817
    [32]
    Jeremy Siek. 2013. Type Safety in Three Easy Lemmas. http://siek.blogspot.de/2013/05/type-safety-in-three-easy-lemmas. html.
    [33]
    Vincent Simonet. 2003a. An extension of HM(X) with bounded existential and universal data-types. In Proceedings of the Eighth ACM SIGPLAN International Conference on Functional Programming, ICFP 2003, Uppsala, Sweden, August 25-29, 2003, Colin Runciman and Olin Shivers (Eds.). ACM, 39-50. https://doi.org/10.1145/944705.944710
    [34]
    Vincent Simonet. 2003b. Type Inference with Structural Subtyping: A Faithful Formalization of an Eficient Constraint Solver. In Programming Languages and Systems, First Asian Symposium, APLAS 2003, Beijing, China, November 27-29, 2003, Proceedings (Lecture Notes in Computer Science, Vol. 2895 ), Atsushi Ohori (Ed.). Springer, 283-302. https: //doi.org/10.1007/978-3-540-40018-9_19
    [35]
    Vincent Simonet and François Pottier. 2007. A Constraint-Based Approach to Guarded Algebraic Data Types. ACM Trans. Program. Lang. Syst. 29, 1 ( 2007 ), 1. https://doi.org/10.1145/1180475.1180476
    [36]
    Christian Skalka and François Pottier. 2002. Syntactic Type Soundness for HM(X). Electr. Notes Theor. Comput. Sci. 75 ( 2002 ), 61-74. https://doi.org/10.1016/S1571-0661 ( 04 ) 80779-5
    [37]
    Jesse A. Tov and Riccardo Pucella. 2011. Practical afine types. In Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011, Thomas Ball and Mooly Sagiv (Eds.). ACM, 447-458. https://doi.org/10.1145/1926385.1926436
    [38]
    Valery Trifonov and Scott F. Smith. 1996. Subtyping Constrained Types. In Static Analysis, Third International Symposium, SAS'96, Aachen, Germany, September 24-26, 1996, Proceedings (Lecture Notes in Computer Science, Vol. 1145 ), Radhia Cousot and David A. Schmidt (Eds.). Springer, 349-365. https://doi.org/10.1007/3-540-61739-6_52
    [39]
    Aaron Weiss, Daniel Patterson, Nicholas D. Matsakis, and Amal Ahmed. 2019. Oxide: The Essence of Rust. CoRR abs/ 1903.00982 ( 2019 ). arXiv: 1903.00982 http://arxiv.org/abs/ 1903.00982

    Cited By

    View all
    • (2024)Functional Ownership through Fractional UniquenessProceedings of the ACM on Programming Languages10.1145/36498488:OOPSLA1(1040-1070)Online publication date: 29-Apr-2024
    • (2023)Kind Inference for the FreeST Programming LanguageElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.378.1378(1-13)Online publication date: 13-Apr-2023
    • (2023)A Survey on Parallelism and DeterminismACM Computing Surveys10.1145/356452955:10(1-28)Online publication date: 2-Feb-2023
    • Show More Cited By

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 4, Issue ICFP
    August 2020
    1070 pages
    EISSN:2475-1421
    DOI:10.1145/3415018
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution International 4.0 License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 03 August 2020
    Published in PACMPL Volume 4, Issue ICFP

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. Functional programming
    2. Linear types
    3. Ownership
    4. Type inference

    Qualifiers

    • Research-article

    Funding Sources

    • German Research Council

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)174
    • Downloads (Last 6 weeks)29
    Reflects downloads up to 10 Aug 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Functional Ownership through Fractional UniquenessProceedings of the ACM on Programming Languages10.1145/36498488:OOPSLA1(1040-1070)Online publication date: 29-Apr-2024
    • (2023)Kind Inference for the FreeST Programming LanguageElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.378.1378(1-13)Online publication date: 13-Apr-2023
    • (2023)A Survey on Parallelism and DeterminismACM Computing Surveys10.1145/356452955:10(1-28)Online publication date: 2-Feb-2023
    • (2022)Linearly qualified types: generic inference for capabilities and uniquenessProceedings of the ACM on Programming Languages10.1145/35476266:ICFP(137-164)Online publication date: 31-Aug-2022
    • (2022)Linearity and Uniqueness: An Entente CordialeProgramming Languages and Systems10.1007/978-3-030-99336-8_13(346-375)Online publication date: 29-Mar-2022

    View Options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Get Access

    Login options

    Full Access

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media