skip to main content

Kindly bent to free us

Published:03 August 2020Publication History
Related Artifact: The Affe typechecker software https://doi.org/10.1145/3410232
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Presentation at ICFP '20

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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Nada Amin and Tiark Rompf. 2017. Type Soundness Proofs With Definitional Interpreters. In POPL. ACM, 666-679.Google ScholarGoogle Scholar
  4. Phil Bagwell. 2001. Ideal Hash Trees.Google ScholarGoogle Scholar
  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= 2837022Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Robert DeLine and Manuel Fähndrich. 2001. Enforcing High-Level Protocols in Low-Level Software. In PLDI. ACM, 59-69.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jean-Yves Girard. 1987. Linear Logic. Theor. Comput. Sci. 50 ( 1987 ), 1-102. https://doi.org/10.1016/ 0304-3975 ( 87 ) 90045-4 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Rich Hickey. 2017. clojure/PersistentHashMap.java. https://github.com/richhickey/clojure/blob/master/src/jvm/clojure/ lang/PersistentHashMap.javaGoogle ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.00268Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Guillaume Munch-Maccagnoni. 2018. Resource Polymorphism. CoRR abs/ 1803.02796 ( 2018 ). arXiv: 1803.02796 http://arxiv.org/abs/ 1803.02796Google ScholarGoogle Scholar
  24. Martin Odersky, Martin Sulzmann, and Martin Wehr. 1999. Type Inference with Constrained Types. TAPOS 5, 1 ( 1999 ), 35-55.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  27. Luca Padovani. 2017. A Simple Library Implementation of Binary Sessions. J. Funct. Program. 27 ( 2017 ), e4. https: //doi.org/10.1017/S0956796816000289 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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-01086106Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  32. Jeremy Siek. 2013. Type Safety in Three Easy Lemmas. http://siek.blogspot.de/2013/05/type-safety-in-three-easy-lemmas. html.Google ScholarGoogle Scholar
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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 Google ScholarGoogle ScholarDigital LibraryDigital Library
  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 Google ScholarGoogle ScholarCross RefCross Ref
  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.00982Google ScholarGoogle Scholar

Index Terms

  1. Kindly bent to free us

      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
      About Cookies On This Site

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

      Learn more

      Got it!