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

Explicit Effects and Effect Constraints in ReML

Published: 05 January 2024 Publication History
  • Get Citation Alerts
  • Abstract

    An important aspect of building robust systems that execute on dedicated hardware and perhaps in constrained environments is to control and manage the effects performed by program code.
    We present ReML, a higher-order statically-typed functional language, which allows programmers to be explicit about the effects performed by program code and in particular effects related to memory management. Allowing programmers to be explicit about effects, the regions in which values reside, and the constraints under which code execute, makes programs robust to changes in the program source code and to compiler updates, including compiler optimisations.
    ReML is integrated with a polymorphic inference system that builds on top of region-inference, as it is implemented in the MLKit, a Standard ML compiler that uses region-based memory management as its primary memory management scheme.

    References

    [1]
    Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic effects and handlers. Journal of Logical and Algebraic Methods in Programming, 84, 1 (2015), jan, 108–123. https://doi.org/10.1016/j.jlamp.2014.02.001
    [2]
    Lars Birkedal and Mads Tofte. 2001. A constraint-based region inference algorithm. Theoretical Computer Science, 258, 1 (2001), 299–392. issn:0304-3975 https://doi.org/10.1016/S0304-3975(00)00025-6
    [3]
    Lars Birkedal, Mads Tofte, and Magnus Vejlstrup. 1996. From Region Inference to von Neumann Machines via Region Representation Inference. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’96). Association for Computing Machinery, New York, NY, USA. 171–183. isbn:0897917693 https://doi.org/10.1145/237721.237771
    [4]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, Edward Lee, and Aleksander Boruch-Gruszecki. 2022. Effects, Capabilities, and Boxes: From Scope-based Reasoning to Type-based Reasoning and Back. In Proceedings of the International Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/3527320
    [5]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020. Effects as Capabilities: Effect Handlers and Lightweight Effect Polymorphism. In Proceedings of the International Conference on Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). ACM Press. https://doi.org/10.1145/3428194
    [6]
    Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020. Effekt: Capability-passing style for type- and effect-safe, extensible effect handlers in Scala. Journal of Functional Programming, 30 (2020), e8. https://doi.org/10.1017/S0956796820000027
    [7]
    Cristiano Calcagno. 2001. Stratified Operational Semantics for Safety and Correctness of the Region Calculus. In ACM Symposium on Principles of Programming Languages (POPL’01). ACM Press.
    [8]
    Cristiano Calcagno, Simon Helsen, and Peter Thiemann. 2002. Syntactic Type Soundness Results for the Region Calculus. Information and Computation, 173, 2 (2002).
    [9]
    Chiyan Chen and Hongwei Xi. 2005. Combining Programming with Theorem Proving. In Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming (ICFP ’05). Association for Computing Machinery, New York, NY, USA. 66–77. isbn:1595930647 https://doi.org/10.1145/1086365.1086375
    [10]
    E. Cooper and G. Morrisett. 1990. Adding Threads to Standard ML. Carnegie Mellon University, Department of Computer Science. Technical report
    [11]
    Martin Elsman. 1998. Polymorphic Equality - No Tags Required. In Proceedings of the Second International Workshop on Types in Compilation (TIC ’98). Springer-Verlag, Berlin, Heidelberg. 136–155. isbn:3540649255
    [12]
    Martin Elsman. 2011. SMLtoJs: Hosting a Standard ML Compiler in a Web Browser. In Proceedings of the 1st ACM SIGPLAN International Workshop on Programming Language and Systems Technologies for Internet Clients (PLASTIC ’11). Association for Computing Machinery, New York, NY, USA. 39–48. isbn:9781450311717 https://doi.org/10.1145/2093328.2093336
    [13]
    Martin Elsman. 2023. Garbage-Collection Safety for Region-Based Type-Polymorphic Programs. In Proceedings of the 44th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2023). Association for Computing Machinery, New York, NY, USA. https://doi.org/10.1145/3591229
    [14]
    Martin Elsman. 2024. Artifact for the POPL 2024 paper: Explicit Effects and Effect Constraints in ReML. Zenodo. https://doi.org/10.5281/zenodo.8425443
    [15]
    Martin Elsman and Niels Hallenberg. 1995. An Optimizing Backend for the ML Kit Using a Stack of Regions. Student Project 95-7-8, University of Copenhagen (DIKU).
    [16]
    Martin Elsman and Niels Hallenberg. 2021. Integrating region memory management and tag-free generational garbage collection. Journal of Functional Programming, 31 (2021), e4. https://doi.org/10.1017/S0956796821000010
    [17]
    Martin Elsman and Troels Henriksen. 2023. Parallelism in a Region-Inference Context. In Proceedings of the 44th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2023). Association for Computing Machinery, New York, NY, USA. https://doi.org/10.1145/3591256
    [18]
    Manuel Fahndrich, Jeffrey S. Foster, Jason Cu, and Alexander Aiken. 1998. Tracking down Exceptions in Standard ML Programs. EECS Department, University of California, Berkeley. http://www2.eecs.berkeley.edu/Pubs/TechRpts/1998/5561.html
    [19]
    Kavon Farvardin and John Reppy. 2020. From Folklore to Fact: Comparing Implementations of Stacks and Continuations. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI 2020). Association for Computing Machinery, New York, NY, USA. 75–90. isbn:9781450376136 https://doi.org/10.1145/3385412.3385994
    [20]
    Matthew Fluet and Greg Morrisett. 2004. Monadic Regions. In Proceedings of the Ninth ACM SIGPLAN International Conference on Functional Programming (ICFP ’04). Association for Computing Machinery, New York, NY, USA. 103–114. isbn:1581139055 https://doi.org/10.1145/1016850.1016867
    [21]
    Matthew Fluet, Mike Rainey, John Reppy, and Adam Shaw. 2008. Implicitly-Threaded Parallelism in Manticore. In Proceedings of the 13th ACM SIGPLAN International Conference on Functional Programming (ICFP ’08). Association for Computing Machinery, New York, NY, USA. 119–130. isbn:9781595939197 https://doi.org/10.1145/1411204.1411224
    [22]
    Jeffrey S. Foster, Tachio Terauchi, and Alex Aiken. 2002. Flow-Sensitive Type Qualifiers. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation (PLDI ’02). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:1581134630 https://doi.org/10.1145/512529.512531
    [23]
    Tim Freeman and Frank Pfenning. 1991. Refinement Types for ML. In Proceedings of the ACM SIGPLAN 1991 Conference on Programming Language Design and Implementation (PLDI ’91). Association for Computing Machinery, New York, NY, USA. 268–277. isbn:0897914287 https://doi.org/10.1145/113445.113468
    [24]
    David Gay and Alex Aiken. 1998. Memory Management with Explicit Regions. In Proceedings of the ACM SIGPLAN 1998 Conference on Programming Language Design and Implementation (PLDI ’98). Association for Computing Machinery, New York, NY, USA. 313–323. isbn:0897919874 https://doi.org/10.1145/277650.277748
    [25]
    Prodromos Gerakios, Nikolaos Papaspyrou, and Konstantinos Sagonas. 2010. Race-Free and Memory-Safe Multithreading: Design and Implementation in Cyclone. In Proceedings of the 5th ACM SIGPLAN Workshop on Types in Language Design and Implementation (TLDI ’10). Association for Computing Machinery, New York, NY, USA. 15–26. isbn:9781605588919 https://doi.org/10.1145/1708016.1708020
    [26]
    Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney. 2002. Region-Based Memory Management in Cyclone. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation (PLDI ’02). Association for Computing Machinery, New York, NY, USA. 282–293. isbn:1581134630 https://doi.org/10.1145/512529.512563
    [27]
    Cordelia V. Hall, Kevin Hammond, Simon L. Peyton Jones, and Philip L. Wadler. 1996. Type classes in Haskell. ACM Transactions on Programming Languages and Systems, 18, 2 (1996), 109–138.
    [28]
    Niels Hallenberg. 1996. A Region Profiler for a Standard ML compiler based on Region Inference. Student Project 96-5-7, Department of Computer Science, University of Copenhagen (DIKU).
    [29]
    Niels Hallenberg, Martin Elsman, and Mads Tofte. 2002. Combining Region Inference and Garbage Collection. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming Language Design and Implementation (PLDI ’02). Association for Computing Machinery, New York, NY, USA. 141–152. isbn:1581134630 https://doi.org/10.1145/512529.512547
    [30]
    Simon Helsen and Peter Thiemann. 2001. Syntactic Type Soundness for the Region Calculus. Electronic Notes in Theoretical Computer Science, 41, 3 (2001), 1–19. issn:1571-0661 https://doi.org/10.1016/S1571-0661(04)80870-3 HOOTS 2000, 4th International Workshop on Higher Order Operational Techniques in Semantics (Satellite to PLI 2000)
    [31]
    Fritz Henglein, Henning Makholm, and Henning Niss. 2001. A Direct Approach to Control-Flow Sensitive Region-Based Memory Management. Proceedings of the 3rd International ACM SIGPLAN Conference on Principles and Practice of Declarative Programming, 07, https://doi.org/10.1145/773184.773203
    [32]
    Michael Hicks, Greg Morrisett, Dan Grossman, and Trevor Jim. 2004. Experience with Safe Manual Memory-Management in Cyclone. In Proceedings of the 4th International Symposium on Memory Management (ISMM ’04). Association for Computing Machinery, New York, NY, USA. 73–84. isbn:1581139454 https://doi.org/10.1145/1029873.1029883
    [33]
    Mark P. Jones. 1994. A theory of qualified types. Science of Computer Programming, 22, 3 (1994), 231–256. issn:0167-6423 https://doi.org/10.1016/0167-6423(94)00005-0
    [34]
    Pierre Jouvelot and David Gifford. 1991. Algebraic Reconstruction of Types and Effects. In Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’91). Association for Computing Machinery, New York, NY, USA. 303–310. isbn:0897914198 https://doi.org/10.1145/99583.99623
    [35]
    Ralf Jung, Jacques-Henri Jourdan, Robbert Krebbers, and Derek Dreyer. 2017. RustBelt: Securing the Foundations of the Rust Programming Language. Proc. ACM Program. Lang., 2, POPL (2017), Article 66, dec, 34 pages. https://doi.org/10.1145/3158154
    [36]
    Oleg Kiselyov, Yukiyoshi Kameyama, and Yuto Sudo. 2016. Refined Environment Classifiers - Type- and Scope-Safe Code Generation with Mutable Cells. In Programming Languages and Systems - 14th Asian Symposium, APLAS 2016, Hanoi, Vietnam, November 21-23, 2016, Proceedings, Atsushi Igarashi (Ed.) (Lecture Notes in Computer Science, Vol. 10017). 271–291. https://doi.org/10.1007/978-3-319-47958-3_15
    [37]
    Oleg Kiselyov and Chung-chieh Shan. 2008. Lightweight Monadic Regions. In Proceedings of the First ACM SIGPLAN Symposium on Haskell (Haskell ’08). Association for Computing Machinery, New York, NY, USA. 1–12. isbn:9781605580647 https://doi.org/10.1145/1411286.1411288
    [38]
    Steve Klabnik and Carol Nichols. 2018. The Rust Programming Language. No Starch Press, USA. isbn:1593278284
    [39]
    Daan Leijen. 2014. Koka: Programming with Row Polymorphic Effect Types. Electronic Proceedings in Theoretical Computer Science, 153 (2014), 06, https://doi.org/10.4204/EPTCS.153.8
    [40]
    J. M. Lucassen and D. K. Gifford. 1988. Polymorphic Effect Systems. In Proceedings of the 15th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’88). Association for Computing Machinery, New York, NY, USA. 47–57. isbn:0897912527 https://doi.org/10.1145/73560.73564
    [41]
    Matthew Lutze, Magnus Madsen, Philipp Schuster, and Jonathan Immanuel Brachthäuser. 2023. With or Without You: Programming with Effect Exclusion. Proc. ACM Program. Lang., 7, ICFP (2023), Article 204, aug, 28 pages. https://doi.org/10.1145/3607846
    [42]
    Greg Morrisett. 1995. Compiling with Types. Ph. D. Dissertation. School of Computer Science, Carnegie Mellon University, Pittsburgh, PA 15213.
    [43]
    Martin Odersky, Martin Sulzmann, and Martin Wehr. 1999. Type inference with constrained types. Theory and Practice of Object Systems, 5, 1 (1999), 35–55. https://doi.org/10.1002/(SICI)1096-9942(199901/03)5:1<35::AID-TAPO4>3.0.CO;2-4
    [44]
    Lars Pareto. 2000. Types for Crash Prevention. Ph. D. Dissertation. Chalmers University of Technology, Gothenburg University, Gothenburg, Sweden.
    [45]
    François Pessaux and Xavier Leroy. 1999. Type-Based Analysis of Uncaught Exceptions. ACM Transactions on Programming Languages and Systems, 22, 276–290. isbn:1581130953 https://doi.org/10.1145/292540.292565
    [46]
    John Peterson and Mark Jones. 1993. Implementing Type Classes. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation (PLDI ’93). Association for Computing Machinery, New York, NY, USA. 227–236. isbn:0897915984 https://doi.org/10.1145/155090.155112
    [47]
    Ram Raghunathan, Stefan K. Muller, Umut A. Acar, and Guy Blelloch. 2016. Hierarchical Memory Management for Parallel Programs. In Proceedings of the 21st ACM SIGPLAN International Conference on Functional Programming (ICFP 2016). Association for Computing Machinery, New York, NY, USA. 392–406. isbn:9781450342193 https://doi.org/10.1145/2951913.2951935
    [48]
    KC Sivaramakrishnan, Stephen Dolan, Leo White, Sadiq Jaffer, Tom Kelly, Anmol Sahoo, Sudha Parimala, Atul Dhiman, and Anil Madhavapeddy. 2020. Retrofitting Parallelism onto OCaml. Proc. ACM Program. Lang., 4, ICFP (2020), Article 113, Aug., 30 pages. https://doi.org/10.1145/3408995
    [49]
    Martin Franz Sulzmann and Paul Hudak. 2000. A General Framework for Hindley/Milner Type Systems with Constraints. Ph. D. Dissertation. USA. isbn:0599791896 AAI9973781
    [50]
    Nikhil Swamy, Michael Hicks, Greg Morrisett, Dan Grossman, and Trevor Jim. 2006. Safe manual memory management in Cyclone. Science of Computer Programming, 62, 2 (2006), 122–144. issn:0167-6423 https://doi.org/10.1016/j.scico.2006.02.003 Special Issue: Five perspectives on modern memory management - Systems, hardware and theory
    [51]
    Jean-Pierre Talpin and Pierre Jouvelot. 1994. The Type and Effect Discipline. Inf. Comput., 111, 2 (1994), jun, 245–296. issn:0890-5401 https://doi.org/10.1006/inco.1994.1046
    [52]
    Mads Tofte and Lars Birkedal. 1998. A Region Inference Algorithm. ACM Trans. Program. Lang. Syst., 20, 4 (1998), jul, 724–767. issn:0164-0925 https://doi.org/10.1145/291891.291894
    [53]
    Mads Tofte and Lars Birkedal. 2000. Unification and Polymorphism in Region Inference. Proof, Language, and Interaction. Essays in Honour of Robin Milner, May, (25 pages)
    [54]
    Mads Tofte, Lars Birkedal, Martin Elsman, and Niels Hallenberg. 2004. A Retrospective on Region-Based Memory Management. Higher-Order and Symbolic Computation, 17, 3 (2004), 01 Sep, 245–265. https://doi.org/10.1023/B:LISP.0000029446.78563.a4
    [55]
    Mads Tofte, Lars Birkedal, Martin Elsman, Niels Hallenberg, Tommy Højfeld Olesen, and Peter Sestoft. 2022. Programming with Regions in the MLKit (Revised for Version 4.7.2). IT University of Copenhagen, Denmark.
    [56]
    Mads Tofte and Jean-Pierre Talpin. 1997. Region-Based Memory Management. Information and Computation, 132, 2 (1997), 109–176. issn:0890-5401 https://doi.org/10.1006/inco.1996.2613
    [57]
    Niki Vazou, Eric L. Seidel, Ranjit Jhala, Dimitrios Vytiniotis, and Simon Peyton-Jones. 2014. Refinement Types for Haskell. In Proceedings of the 19th ACM SIGPLAN International Conference on Functional Programming (ICFP ’14). Association for Computing Machinery, New York, NY, USA. 269–282. isbn:9781450328739 https://doi.org/10.1145/2628136.2628161
    [58]
    David Walker, Karl Crary, and Greg Morrisett. 2000. Typed Memory Management via Static Capabilities. ACM Trans. Program. Lang. Syst., 22, 4 (2000), jul, 701–771. issn:0164-0925 https://doi.org/10.1145/363911.363923
    [59]
    Sam Westrick, Jatin Arora, and Umut A. Acar. 2022. Entanglement Detection with Near-Zero Cost. Proc. ACM Program. Lang., 6, ICFP (2022), Article 115, aug, 32 pages. https://doi.org/10.1145/3547646
    [60]
    Sam Westrick, Rohan Yadav, Matthew Fluet, and Umut A. Acar. 2019. Disentanglement in Nested-Parallel Programs. Proc. ACM Program. Lang., 4, POPL (2019), Article 47, Dec., 32 pages. https://doi.org/10.1145/3371115
    [61]
    A.K. Wright and M. Felleisen. 1994. A Syntactic Approach to Type Soundness. Inf. Comput., 115, 1 (1994), nov, 38–94. issn:0890-5401 https://doi.org/10.1006/inco.1994.1093

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image Proceedings of the ACM on Programming Languages
    Proceedings of the ACM on Programming Languages  Volume 8, Issue POPL
    January 2024
    2820 pages
    EISSN:2475-1421
    DOI:10.1145/3554315
    Issue’s Table of Contents
    This work is licensed under a Creative Commons Attribution 4.0 International License.

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 05 January 2024
    Published in PACMPL Volume 8, Issue POPL

    Permissions

    Request permissions for this article.

    Check for updates

    Badges

    Author Tags

    1. Effect Systems
    2. Memory Management
    3. Parallelism
    4. Region-inference

    Qualifiers

    • Research-article

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • 0
      Total Citations
    • 248
      Total Downloads
    • Downloads (Last 12 months)248
    • Downloads (Last 6 weeks)31
    Reflects downloads up to 11 Aug 2024

    Other Metrics

    Citations

    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