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

Effectful Software Contracts

Published: 05 January 2024 Publication History

Abstract

Software contracts empower programmers to describe functional properties of components. When it comes to constraining effects, though, the literature offers only one-off solutions for various effects. It lacks a universal principle. This paper presents the design of an effectful contract system in the context of effect handlers. A key metatheorem shows that contracts cannot unduly interfere with a program's execution. An implementation of this design, along with an evaluation of its generality, demonstrates that the theory can guide practice.

References

[1]
Danel Ahman and Andrej Bauer. 2020. Runners in Action. In European Symposium on Programming (ESOP). https://doi.org/10.1007/978-3-030-44914-8_2
[2]
Leif Andersen, Vincent St-Amour, Jan Vitek, and Matthias Felleisen. 2018. Feature-Specific Profiling. Transactions on Programming Languages and Systems (TOPLAS), https://doi.org/10.1145/3275519
[3]
Felipe Bañados Schwerter. 2016. Side Effects Take the Blame. In Software Language Engineering (SLE). https://doi.org/10.1145/2997364.2997381
[4]
Felipe Bañados Schwerter, Ronald Garcia, and Éric Tanter. 2014. A Theory of Gradual Effect Systems. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/2692915.2628149
[5]
Hendrik Pieter Barendregt. 1981. The Lambda Calculus. North-Holland Publishing Co.
[6]
Lawrence E. Bassham, Andrew L. Rukhin, Juan Soto, James R. Nechvatal, Miles E. Smid, Elaine B. Barker, Stefan D. Leigh, Mark Levenson, Mark Vangel, David L. Banks, Nathanael Alan Heckert, James F. Dray, and San Vo. 2010. A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications. National Institute of Standards and Technology. https://csrc.nist.gov/publications/detail/sp/800-22/rev-1a/final
[7]
Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2017. Handle with Care: Relational Interpretation of Algebraic Effects and Handlers. In Principles of Programming Languages (POPL). https://doi.org/10.1145/3158096
[8]
Matthias Blume and David McAllester. 2006. Sound and Complete Models of Contracts. Journal of Functional Programming (JFP), https://doi.org/10.1017/S0956796806005971
[9]
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 Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/3527320
[10]
Robert Cartwright and Matthias Felleisen. 1994. Extensible Denotational Language Specifications. In Theoretical Aspects of Computer Software (TACS). https://doi.org/10.1007/3-540-57887-0_99
[11]
Patrice Chalin, Joseph R. Kiniry, Gary T. Leavens, and Erik Poll. 2006. Beyond Assertions: Advanced Specification and Verification with JML and ESC/Java2. In Formal Methods for Components and Objects. https://doi.org/10.1007/11804192_16
[12]
Sivaramakrishnan Krishnamoorthy Chandrasekaran, Daan Leijen, Matija Pretnar, and Tom Schrijvers. 2018. Algebraic Effect Handlers go Mainstream (Dagstuhl Seminar 18172). Dagstuhl Reports, https://doi.org/10.4230/DagRep.8.4.104
[13]
John Clements and Matthias Felleisen. 2004. A Tail-Recursive Machine with Stack Inspection. In Transactions on Programming Languages and Systems (TOPLAS). https://doi.org/10.1145/1034774.1034778
[14]
John Clements, Matthew Flatt, and Matthias Felleisen. 2001. Modeling an Algebraic Stepper. In European Symposium on Programming (ESOP). https://doi.org/10.1007/3-540-45309-1_21
[15]
H.B. Curry and R. Feys. 1958. Combinatory Logic, Volume I. North-Holland, Amsterdam.
[16]
Jeffrey Dean and Sanjay Ghemawat. 2008. MapReduce: Simplified Data Processing on Large Clusters. Communications of the ACM (CACM), https://doi.org/10.1145/1327452.1327492
[17]
Jack B. Dennis and Earl C. Van Horn. 1966. Programming Semantics for Multiprogrammed Computations. Communications of the ACM (CACM), https://doi.org/10.1145/365230.365252
[18]
Christos Dimoulas and Matthias Felleisen. 2011. On Contract Satisfaction in a Higher-Order World. Transactions on Programming Languages and Systems (TOPLAS), https://doi.org/10.1145/2039346.2039348
[19]
Christos Dimoulas, Robert Bruce Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct Blame for Contracts: No More Scapegoating. In Principles of Programming Languages (POPL). https://doi.org/10.1145/1926385.1926410
[20]
Christos Dimoulas, Max S. New, Robert Bruce Findler, and Matthias Felleisen. 2016. Oh Lord, Please Don’t Let Contracts Be Misunderstood (Functional Pearl). In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/2951913.2951930
[21]
Christos Dimoulas, Sam Tobin-Hochstadt, and Matthias Felleisen. 2012. Complete Monitors for Behavioral Contracts. In European Symposium on Programming (ESOP). https://doi.org/10.1007/978-3-642-28869-2_11
[22]
Tim Disney, Cormac Flanagan, and Jay McCarthy. 2011. Temporal Higher-Order Contracts. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/2034773.2034800
[23]
Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In Principles of Programming Languages (POPL). https://doi.org/10.1145/73560.73576
[24]
Matthias Felleisen. 1991. On the Expressive Power of Programming Languages. Science of Computer Programming, https://doi.org/10.1016/0167-6423(91)90036-W
[25]
Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press.
[26]
Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi, Eli Barzilay, Jay McCarthy, and Sam Tobin-Hochstadt. 2018. A Programmable Programming Language. Communications of the ACM (CACM), https://doi.org/10.1145/3127323
[27]
Matthias Felleisen and Robert Hieb. 1992. The Revised Report on the Syntactic Theories of Sequential Control and State. In Theoretical Computer Science. https://doi.org/10.1016/0304-3975(92)90014-7
[28]
Robert Bruce Findler and Matthias Blume. 2006. Contracts as Pairs of Projections. In Functional and Logic Programming (FLP). https://doi.org/10.1007/11737414_16
[29]
Robert Bruce Findler and Matthias Felleisen. 2001. Contract Soundness for Object-Oriented Languages. In Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/504311.504283
[30]
Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for Higher-Order Functions. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/581478.581484
[31]
Matthew Flatt and R. Kent Dybvig. 2020. Compiler and Runtime Support for Continuation Marks. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/3385412.3385981
[32]
Matthew Flatt and PLT. 2010. Reference: Racket. PLT Design Inc. https://racket-lang.org/tr1/
[33]
Matthew Flatt, Gang Yu, Robert Bruce Findler, and Matthias Felleisen. 2007. Adding Delimited and Composable Control to a Production Programming Environment. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/1291151.1291178
[34]
Teodoro Freund, Yann Hamdaoui, and Arnaud Spiwack. 2021. Union and Intersection Contracts Are Hard, Actually. In Dynamic Languages Symposium (DLS). https://doi.org/10.1145/3486602.3486767
[35]
Michael Greenberg, Benjamin C. Pierce, and Stephanie Weirich. 2010. Contracts Made Manifest. In Principles of Programming Languages (POPL). https://doi.org/10.1145/1706299.1706341
[36]
Daniel Hillerström and Sam Lindley. 2018. Shallow Effect Handlers. In Asian Symposium on Programming Languages and Systems (APLAS). https://doi.org/10.1007/978-3-030-02768-1_22
[37]
Matthias Keil and Peter Thiemann. 2015. Blame Assignment for Higher-Order Contracts with Intersection and Union. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/2784731.2784737
[38]
Matthias Keil and Peter Thiemann. 2015. TreatJS: Higher-Order Contracts for JavaScripts. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.4230/LIPIcs.ECOOP.2015.28
[39]
Lukas Lazarek, Alexis King, Samanvitha Sundar, Robert Bruce Findler, and Christos Dimoulas. 2020. Does Blame Shifting Work? In Principles of Programming Languages (POPL). https://doi.org/10.1145/3371133
[40]
Daan Leijen. 2013. Koka: Programming with Row-Polymorphic Effect Types. Microsoft Research. https://www.microsoft.com/en-us/research/publication/koka-programming-with-row-polymorphic-effect-types/
[41]
Jacob Matthews and Robert Bruce Findler. 2007. Operational Semantics for Multi-Language Programs. In Principles of Programming Languages (POPL). https://doi.org/10.1145/1498926.1498930
[42]
Bertrand Meyer. 1988. Object-Oriented Software Construction. Prentice Hall.
[43]
Bertrand Meyer. 1992. Applying “Design by Contract”. Computer, https://doi.org/10.1109/2.161279
[44]
Scott Moore, Christos Dimoulas, Robert Bruce Findler, Matthew Flatt, and Stephen Chong. 2016. Extensible Access Control with Authorization Contracts. In Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/2983990.2984021
[45]
Cameron Moy, Christos Dimoulas, and Matthias Felleisen. 2023. Artifact: Effectful Software Contracts. https://doi.org/10.5281/zenodo.10151333
[46]
Cameron Moy and Matthias Felleisen. 2023. Trace Contracts. Journal of Functional Programming (JFP), https://doi.org/10.1017/S0956796823000096
[47]
Phúc C. Nguyễn, Thomas Gilray, Sam Tobin-Hochstadt, and David Van Horn. 2018. Soft Contract Verification for Higher-Order Stateful Programs. In Principles of Programming Languages (POPL). https://doi.org/10.1145/3158139
[48]
Phúc C. Nguyễn, Thomas Gilray, Sam Tobin-Hochstadt, and David Van Horn. 2019. Size-Change Termination as a Contract. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/3325984
[49]
Bruno C. D. S. Oliveira, Tom Schrijvers, and William R. Cook. 2012. MRI: Modular Reasoning About Interference in Incremental Programming. Journal of Functional Programming (JFP), https://doi.org/10.1017/S0956796812000354
[50]
Gordon Plotkin. 1975. Call-by-name, call-by-value and the λ -calculus. Theoretical Computer Science, https://doi.org/10.1016/0304-3975(75)90017-1
[51]
Gordon Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Effects. In European Symposium on Programming (ESOP). https://doi.org/10.1007/978-3-642-00590-9_7
[52]
Matija Pretnar. 2015. An Introduction to Algebraic Effects and Handlers. In Mathematical Foundations of Programming Semantics (MFPS). https://doi.org/10.1016/j.entcs.2015.12.003
[53]
R. L. Rivest, A. Shamir, and A. Adleman. 1978. A Method for Obtaining Digital Signatures and Public-Key Cryptosystems. In Communications of the ACM (CACM). https://doi.org/10.1145/359340.359342
[54]
Christophe Scholliers, Éric Tanter, and Wolfgang De Meuter. 2015. Computational Contracts. Science of Computer Programming, https://doi.org/10.1016/j.scico.2013.09.005
[55]
Avraham Ever Shinnar. 2011. Safe and Effective Contracts. Ph. D. Dissertation. Harvard University.
[56]
Dorai Sitaram and Matthias Felleisen. 1990. Control Delimiters and Their Hierarchies. Lisp and Symbolic Computation, https://doi.org/10.1007/BF01806126
[57]
T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and Impersonators: Run-Time Support for Reasonable Interposition. In Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/2384616.2384685
[58]
Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt, and Matthias Felleisen. 2011. Languages as Libraries. In Programming Language Design and Implementation (PLDI). https://doi.org/10.1145/1993316.1993514
[59]
Jesse A. Tov and Riccardo Pucella. 2010. Stateful Contracts for Affine Types. In European Symposium on Programming (ESOP). https://doi.org/10.1007/978-3-642-11957-6_29
[60]
Jack Williams, J. Garrett Morris, and Philip Wadler. 2018. The Root Cause of Blame: Contracts for Intersection and Union Types. In Object-Oriented Programming, Systems, Languages and Applications (OOPSLA). https://doi.org/10.1145/3276504
[61]
Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Information and Computation, https://doi.org/10.1006/inco.1994.1093
[62]
Ningning Xie, Jonathan Immanuel Brachthäuser, Daniel Hillerström, Philipp Schuster, and Daan Leijen. 2020. Effect Handlers, Evidently. In International Conference on Functional Programming (ICFP). https://doi.org/10.1145/3408981
[63]
Dana N. Xu. 2012. Hybrid Contract Checking via Symbolic Simplification. In Partial Evaluation and Program Manipulation (PEPM). https://doi.org/10.1145/2103746.2103767
[64]
Dana N. Xu. 2014. Dynamic Contract Checking for OCaml. http://gallium.inria.fr/ naxu/research/camlcontract.pdf
[65]
Dana N. Xu, Simon Peyton Jones, and Koen Claessen. 2009. Static Contract Checking for Haskell. In Principles of Programming Languages (POPL). https://doi.org/10.1145/1480881.1480889
[66]
Yizhou Zhang and Andrew C. Myers. 2019. Abstraction-Safe Effect Handlers via Tunneling. In Principles of Programming Languages (POPL). https://doi.org/10.1145/3290318

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 handlers
  2. software contracts

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • 0
    Total Citations
  • 336
    Total Downloads
  • Downloads (Last 12 months)336
  • Downloads (Last 6 weeks)43
Reflects downloads up to 15 Oct 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