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

Abstracting algebraic effects

Published: 02 January 2019 Publication History

Abstract

Proposed originally by Plotkin and Pretnar, algebraic effects and their handlers are a leading-edge approach to computational effects: exceptions, mutable state, nondeterminism, and such. Appreciated for their elegance and expressiveness, they are now progressing into mainstream functional programming languages. In this paper, we introduce and examine programming language constructs that back adoption of programming with algebraic effects on a larger scale in a modular fashion by providing mechanisms for abstraction. We propose two such mechanisms: existential effects (which hide the details of a particular effect from the user) and local effects (which guarantee that no code coming from the outside can interfere with a given effect). The main technical difficulty arises from the dynamic nature of coupling an effectful operation with the right handler during execution, but, as we show in this paper, a carefully designed type system can ensure that this will not break the abstraction. Our main contribution is a novel calculus for algebraic effects and handlers, called λHEL, equipped with local and existential algebraic effects, in which the dynamic nature of handlers is kept in check by typed runtime coercions. As a proof of concept, we present an experimental programming language based on our calculus, which provides strong abstraction mechanisms via an ML-style module system.

Supplementary Material

WEBM File (a6-biernacki.webm)

References

[1]
Andrej Bauer and Matija Pretnar. 2014. An Effect System for Algebraic Effects and Handlers. Logical Methods in Computer Science 10, 4:9 (2014), 1–29.
[2]
Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic effects and handlers. J. Log. Algebr. Meth. Program. 84, 1 (2015), 108–123.
[3]
Malgorzata Biernacka, Dariusz Biernacki, and Olivier Danvy. 2005. An Operational Foundation for Delimited Continuations in the CPS Hierarchy. Logical Methods in Computer Science 1, 2:5 (2005), 1–39.
[4]
Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2018. Handle with care: Relational interpretation of algebraic effects and handlers. PACMPL 2, POPL (2018), 8:1–8:30.
[5]
Giuseppe Castagna and Andrew D. Gordon (Eds.). 2017. Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. ACM.
[6]
John Clements and Matthias Felleisen. 2004. A tail-recursive machine with stack inspection. ACM Trans. Program. Lang. Syst. 26, 6 (2004), 1029–1052.
[7]
William D. Clinger. 1998. Proper Tail Recursion and Space Efficiency. In Proceedings of the ACM SIGPLAN ’98 Conference on Programming Language Design and Implementation (PLDI), Montreal, Canada, June 17-19, 1998, Jack W. Davidson, Keith D. Cooper, and A. Michael Berman (Eds.). ACM, 174–185.
[8]
Guy Cousineau, Pierre-Louis Curien, and Michel Mauny. 1985. The Categorical Abstract Machine. In Functional Programming Languages and Computer Architecture, FPCA 1985, Nancy, France, September 16-19, 1985, Proceedings (Lecture Notes in Computer Science), Jean-Pierre Jouannaud (Ed.), Vol. 201. Springer, 50–64.
[9]
R. Kent Dybvig, Simon L. Peyton Jones, and Amr Sabry. 2007. A monadic framework for delimited continuations. J. Funct. Program. 17, 6 (2007), 687–730.
[10]
Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In Conference Record of the Fifteenth Annual ACM Symposium on Principles of Programming Languages, San Diego, California, USA, January 10-13, 1988, Jeanne Ferrante and P. Mager (Eds.). ACM Press, 180–190.
[11]
Matthias Felleisen and Daniel P. Friedman. 1986. Control Operators, the SECD Machine, and the λ-Calculus. In Formal Description of Programming Concepts III, Martin Wirsing (Ed.). Elsevier Science Publishers B.V. (North-Holland), Amsterdam, 193–217.
[12]
Robert Harper. 2016. Practical Foundations for Programming Languages (2nd ed.). Cambridge University Press, New York, NY, USA.
[13]
Daniel Hillerström and Sam Lindley. 2016. Liberating effects with rows and handlers. In Proceedings of the 1st International Workshop on Type-Driven Development, TyDe@ICFP 2016, Nara, Japan, September 18, 2016, James Chapman and Wouter Swierstra (Eds.). ACM, 15–27.
[14]
Gerard Huet. 1976. Resolution d’equation dans les langages d’ordre 1, 2, . . . , ω. Ph.D. Dissertation. Université de Paris VII, France.
[15]
Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In ACM SIGPLAN International Conference on Functional Programming, ICFP’13, Boston, MA, USA - September 25 - 27, 2013, Greg Morrisett and Tarmo Uustalu (Eds.). ACM, 145–158.
[16]
Kevin Knight. 1989. Unification: A Multidisciplinary Survey. ACM Comput. Surv. 21, 1 (1989), 93–124.
[17]
Jean-Louis Krivine. 2007. A call-by-name lambda-calculus machine. Higher-Order and Symbolic Computation 20, 3 (2007), 199–207.
[18]
Peter J. Landin. 1964. The Mechanical Evaluation of Expressions. Comput. J. 6, 4 (1964), 308–320.
[19]
Daan Leijen. 2014. Koka: Programming with Row Polymorphic Effect Types. In Proceedings 5th Workshop on Mathematically Structured Functional Programming, MSFP@ETAPS 2014, Grenoble, France, 12 April 2014. 100–126.
[20]
Daan Leijen. 2017. Type directed compilation of row-typed algebraic effects, See { Castagna and Gordon 2017 }, 486–499.
[21]
Daan Leijen. 2018. Algebraic Effect Handlers with Resources and Deep Finalization. Technical Report MSR-TR-2018-10. Microsoft Research.
[22]
Xavier Leroy. 1990. The Zinc experiment: an economical implementation of the ML language. Rapport Technique 117. INRIA Rocquencourt, Le Chesnay, France.
[23]
Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do, See { Castagna and Gordon 2017 }, 500–514.
[24]
Simon Marlow and Simon L. Peyton Jones. 2006. Making a fast curry: push/enter vs. eval/apply for higher-order languages. J. Funct. Program. 16, 4-5 (2006), 415–449.
[25]
Simon Peyton Jones (Ed.). 2003. Haskell 98 Language and Libraries – The Revised Report. Cambridge University Press, Cambridge, England.
[26]
Simon L. Peyton Jones. 1992. Implementing Lazy Functional Languages on Stock Hardware: The Spineless Tagless G-Machine. J. Funct. Program. 2, 2 (1992), 127–202.
[27]
Benjamin C. Pierce. 2002. Types and programming languages. The MIT Press.
[28]
Gordon D. Plotkin and A. John Power. 2004. Computational Effects and Operations: An Overview. Electronic Notes in Theoretical Computer Science 73 (2004), 149–163.
[29]
Gordon D. Plotkin and John Power. 2001. Semantics for Algebraic Operations. Electr. Notes Theor. Comput. Sci. 45 (2001), 332–345.
[30]
Gordon D. Plotkin and John Power. 2002. Notions of Computation Determine Monads. In Foundations of Software Science and Computation Structures, 5th International Conference, FOSSACS 2002. Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2002 Grenoble, France, April 8-12, 2002, Proceedings (Lecture Notes in Computer Science), Mogens Nielsen and Uffe Engberg (Eds.), Vol. 2303. Springer, 342–356.
[31]
Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Effects. Logical Methods in Computer Science 9, 4:23 (2013), 1–36.
[32]
Amr Hany Saleh, Georgios Karachalias, Matija Pretnar, and Tom Schrijvers. 2018. Explicit Effect Subtyping. In Programming Languages and Systems - 27th European Symposium on Programming, ESOP 2018, Held as Part of the European Joint Conferences on Theory and Practice of Software, ETAPS 2018, Thessaloniki, Greece, April 14-20, 2018, Proceedings (Lecture Notes in Computer Science), Amal Ahmed (Ed.), Vol. 10801. Springer, 327–354.
[33]
Mads Tofte and Jean-Pierre Talpin. 1997. Region-based Memory Management. Inf. Comput. 132, 2 (1997), 109–176.
[34]
Andrew K. Wright and Matthias Felleisen. 1994. A Syntactic Approach to Type Soundness. Inf. Comput. 115, 1 (1994), 38–94.

Cited By

View all
  • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
  • (2024)Soundly Handling LinearityProceedings of the ACM on Programming Languages10.1145/36328968:POPL(1600-1628)Online publication date: 5-Jan-2024
  • (2023)A General Fine-Grained Reduction Theory for Effect HandlersProceedings of the ACM on Programming Languages10.1145/36078487:ICFP(511-540)Online publication date: 31-Aug-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 3, Issue POPL
January 2019
2275 pages
EISSN:2475-1421
DOI:10.1145/3302515
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: 02 January 2019
Published in PACMPL Volume 3, Issue POPL

Permissions

Request permissions for this article.

Check for updates

Badges

Author Tags

  1. algebraic effect
  2. existential type
  3. row polymorphism

Qualifiers

  • Research-article

Funding Sources

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)240
  • Downloads (Last 6 weeks)33
Reflects downloads up to 16 Oct 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Abstracting Effect Systems for Algebraic Effect HandlersProceedings of the ACM on Programming Languages10.1145/36746418:ICFP(455-484)Online publication date: 15-Aug-2024
  • (2024)Soundly Handling LinearityProceedings of the ACM on Programming Languages10.1145/36328968:POPL(1600-1628)Online publication date: 5-Jan-2024
  • (2023)A General Fine-Grained Reduction Theory for Effect HandlersProceedings of the ACM on Programming Languages10.1145/36078487:ICFP(511-540)Online publication date: 31-Aug-2023
  • (2023)A Type System for Effect Handlers and Dynamic LabelsProgramming Languages and Systems10.1007/978-3-031-30044-8_9(225-252)Online publication date: 22-Apr-2023
  • (2022)High-level effect handlers in C++Proceedings of the ACM on Programming Languages10.1145/35634456:OOPSLA2(1639-1667)Online publication date: 31-Oct-2022
  • (2022)Bounded Abstract EffectsACM Transactions on Programming Languages and Systems10.1145/349242744:1(1-48)Online publication date: 12-Jan-2022
  • (2022)Automated Temporal Verification for Algebraic EffectsProgramming Languages and Systems10.1007/978-3-031-21037-2_5(88-109)Online publication date: 25-Nov-2022
  • (2022)Region-based Resource Management and Lexical Exception Handlers in Continuation-Passing StyleProgramming Languages and Systems10.1007/978-3-030-99336-8_18(492-519)Online publication date: 29-Mar-2022
  • (2022)Automating the Functional Correspondence Between Higher-Order Evaluators and Abstract MachinesLogic-Based Program Synthesis and Transformation10.1007/978-3-030-98869-2_3(38-59)Online publication date: 13-Mar-2022
  • (2022)What You See Is What You Get: Practical Effect Handlers in Capability-Passing StyleErnst Denert Award for Software Engineering 202010.1007/978-3-030-83128-8_3(15-43)Online publication date: 28-Feb-2022
  • Show More Cited By

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