Abstract
User-defined effects and effect handlers are advertised and advocated as a relatively easy-to-understand and modular approach to delimited control. They offer the ability of suspending and resuming a computation and allow information to be transmitted both ways between the computation, which requests a certain service, and the handler, which provides this service. Yet, a key question remains, to this day, largely unanswered: how does one modularly specify and verify programs in the presence of both user-defined effect handlers and primitive effects, such as heap-allocated mutable state? We answer this question by presenting a Separation Logic with built-in support for effect handlers, both shallow and deep. The specification of a program fragment includes a protocol that describes the effects that the program may perform as well as the replies that it can expect to receive. The logic allows local reasoning via a frame rule and a bind rule. It is based on Iris and inherits all of its advanced features, including support for higher-order functions, user-defined ghost state, and invariants. We illustrate its power via several case studies, including (1) a generic formulation of control inversion, which turns a producer that ``pushes'' elements towards a consumer into a producer from which one can ``pull'' elements on demand, and (2) a simple system for cooperative concurrency, where several threads execute concurrently, can spawn new threads, and communicate via promises.
- Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. Journal of Logical and Algebraic Methods in Programming 84, 1 ( 2015 ), 108-123. http://math.andrej.com/wp-content/uploads/2012/03/ef.pdfGoogle Scholar
Cross Ref
- Andrej Bauer and Matija Pretnar. 2020. Ef. http://www.ef-lang.org/Google Scholar
- Martin Berger. 2009. Program Logics for Sequential Higher-Order Control. In Fundamentals of Software Engineering (Lecture Notes in Computer Science, Vol. 5961 ). Springer, 194-211. http://users.sussex.ac.uk/~mfb21/publications/fsen09/fsen09-short.pdfGoogle Scholar
- Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting algebraic efects. Proceedings of the ACM on Programming Languages 3, POPL ( 2019 ), 6 : 1-6 : 28. http://www.ii.uni.wroc.pl/~mpirog/papers/biernacki-alpopl19.pdfGoogle Scholar
- Jonathan Immanuel Brachthäuser, Philipp Schuster, and Klaus Ostermann. 2020. Efekt: Capability-passing style for type-and efect-safe, extensible efect handlers in Scala. Journal of Functional Programming 30 ( 2020 ), e8. http://ps.informatik.unituebingen.de/publications/brachthaeuser19efekt-revision.pdfGoogle Scholar
- Edwin C. Brady. 2013. Programming and reasoning with algebraic efects and dependent types. In International Conference on Functional Programming (ICFP). 133-144. https://eb.host.cs. st-andrews.ac.uk/drafts/efects.pdfGoogle Scholar
- Edwin C. Brady. 2014. Resource-Dependent Algebraic Efects. In Trends in Functional Programming (TFP) (Lecture Notes in Computer Science, Vol. 8843 ). Springer, 18-33. https://eb.host.cs. st-andrews.ac.uk/drafts/dep-ef.pdfGoogle Scholar
- Tristan Crolard and Emmanuel Polonowski. 2012. Deriving a Floyd-Hoare logic for non-local jumps from a formulaeas-types notion of control. Journal of Logical and Algebraic Methods in Programming 81, 3 ( 2012 ), 181-208. http://cedric.cnam.fr/sys/crolard/publications/Hoare.pdfGoogle Scholar
- Paulo Emílio de Vilhena. 2020. A Separation Logic for Efect Handlers: Coq formalization. https://gitlab.inria.fr/pdevilhe/ hazel.Google Scholar
- Paulo Emílio de Vilhena and François Pottier. 2020a. Control inversion in Multicore OCaml. https://gitlab.inria.fr/pdevilhe/ hazel/-/blob/master/src/invert.ml.Google Scholar
- Paulo Emílio de Vilhena and François Pottier. 2020b. Cooperative concurrency in Multicore OCaml. https://gitlab.inria.fr/ pdevilhe/hazel/-/blob/master/src/promises.ml.Google Scholar
- Paulo Emílio de Vilhena and François Pottier. 2020c. Problems with multi-shot continuations in Multicore OCaml. https: //gitlab.inria.fr/pdevilhe/hazel/-/blob/master/src/test.ml.Google Scholar
- Germán Andrés Delbianco and Aleksandar Nanevski. 2013. Hoare-style reasoning with (algebraic) continuations. In International Conference on Functional Programming (ICFP). 363-376. http://software.imdea.org/~aleks/papers/callcc/ icfp2013.pdfGoogle Scholar
Digital Library
- 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 (TFP) (Lecture Notes in Computer Science, Vol. 10788 ). Springer, 98-117. http://kcsrk.info/papers/system_efects_feb_18.pdfGoogle Scholar
- Stephan Dolan, Anil Madhavapeddy, and KC Sivaramakrishnan. 2020. Multicore OCaml. https://github.com/ocamlmulticore/ocaml-multicore/wikiGoogle Scholar
- Derek Dreyer, Georg Neis, and Lars Birkedal. 2012. The impact of higher-order state and control efects on local relational reasoning. Journal of Functional Programming 22, 4-5 ( 2012 ), 477-528. https://people.mpi-sws.org/~dreyer/papers/stslr/ journal.pdfGoogle Scholar
Digital Library
- Jean-Christophe Filliâtre and Mário Pereira. 2016. A Modular Way to Reason About Iteration. In NASA Formal Methods (NFM) (Lecture Notes in Computer Science, Vol. 9690 ). Springer, 322-336. https://hal.inria.fr/hal-01281759Google Scholar
- Daniel Hillerström and Sam Lindley. 2018. Shallow Efect Handlers. In Asian Symposium on Programming Languages and Systems (APLAS) (Lecture Notes in Computer Science, Vol. 11275 ). Springer, 415-435. http://homepages.inf.ed.ac.uk/ slindley/papers/shallow-extended.pdfGoogle Scholar
- Daniel Hillerström, Sam Lindley, and Robert Atkey. 2020. Efect handlers via generalised continuations. Journal of Functional Programming 30 ( 2020 ), e5. https://www.dhil.net/research/papers/generalised_continuations-jfp-draft.pdfGoogle Scholar
- Jonas Kastberg Hinrichsen, Jesper Bengtson, and Robbert Krebbers. 2020. Actris: session-type based reasoning in separation logic. Proceedings of the ACM on Programming Languages 4, POPL ( 2020 ), 6 : 1-6 : 30. https://iris-project.org/pdfs/2020-popl-actris-final.pdfGoogle Scholar
Digital Library
- Ralf Jung, Robbert Krebbers, Jacques-Henri Jourdan, Aleš Bizjak, Lars Birkedal, and Derek Dreyer. 2018. Iris from the ground up: A modular foundation for higher-order concurrent separation logic. Journal of Functional Programming 28 ( 2018 ), e20. https://people.mpi-sws.org/~dreyer/papers/iris-ground-up/paper.pdfGoogle Scholar
- Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In International Conference on Functional Programming (ICFP). 145-158. http://homepages.inf.ed.ac.uk/slindley/papers/handlers.pdfGoogle Scholar
Digital Library
- Johannes Kloos, Rupak Majumdar, and Viktor Vafeiadis. 2015. Asynchronous Liquid Separation Types. In European Conference on Object-Oriented Programming (ECOOP). 396-420. https://www.mpi-sws.org/~viktor/papers/ecoop2015-alstypes.pdfGoogle Scholar
- Daan Leijen. 2014. Koka: Programming with Row Polymorphic Efect Types. In Workshop on Mathematically Structured Functional Programming (MSFP), Vol. 153. 100-126. https://www.microsoft.com/en-us/research/wp-content/uploads/ 2016/02/paper-20.pdfGoogle Scholar
- Daan Leijen. 2017. Structured asynchrony with algebraic efects. In Type-Driven Development (TyDe). 16-29. https: //www.microsoft.com/en-us/research/wp-content/uploads/2017/05/asyncefects-msr-tr-2017-21.pdfGoogle Scholar
- Daan Leijen. 2020. Koka. https://www.microsoft.com/en-us/research/project/koka/Google Scholar
- Thomas Letan, Yann Régis-Gianas, Pierre Chiflier, and Guillaume Hiet. 2018. Modular Verification of Programs with Efects and Efect Handlers in Coq. In Formal Methods (FM) (Lecture Notes in Computer Science, Vol. 10951 ). Springer, 338-354. https://hal.inria.fr/hal-01799712Google Scholar
- Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do Be Do Be Do. In Principles of Programming Languages (POPL). http://homepages.inf.ed.ac.uk/slindley/papers/frankly.pdfGoogle Scholar
- Peter W. O'Hearn. 2019. Separation logic. Commun. ACM 62, 2 ( 2019 ), 86-95. https://doi.org/10.1145/3211968 Google Scholar
Digital Library
- Gordon D. Plotkin and A. John Power. 2004. Computational Efects and Operations: An Overview. Electronic Notes in Theoretical Computer Science 73 ( 2004 ), 149-163. https://doi.org/10.1016/j.entcs. 2004. 08.008 Google Scholar
Digital Library
- Gordon D. Plotkin and Matija Pretnar. 2008. A Logic for Algebraic Efects. In Logic in Computer Science (LICS). 118-129. http://homepages.inf.ed.ac.uk/gdp/publications/Logic_Algebraic_Efects.pdfGoogle Scholar
- Gordon D. Plotkin and Matija Pretnar. 2009. Handlers of Algebraic Efects. In European Symposium on Programming (ESOP) (Lecture Notes in Computer Science, Vol. 5502 ). Springer, 80-94. http://homepages.inf.ed.ac.uk/gdp/publications/Efect_Handlers.pdfGoogle Scholar
- Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 (Dec. 2013 ). https://lmcs.episciences. org/705Google Scholar
Cross Ref
- François Pottier. 2017. Verifying a hash table and its iterators in higher-order separation logic. In Certified Programs and Proofs (CPP). 3-16. http://gallium.inria.fr/~fpottier/publis/fpottier-hashtable.pdfGoogle Scholar
Digital Library
- John C. Reynolds. 2002. Separation Logic: A Logic for Shared Mutable Data Structures. In Logic in Computer Science (LICS). 55-74. http://www.cs.cmu.edu/~jcr/seplogic.pdfGoogle Scholar
- Amin Timany and Lars Birkedal. 2019. Mechanized Relational Verification of Concurrent Programs with Continuations. Proceedings of the ACM on Programming Languages 3, ICFP ( July 2019 ), 105 : 1-105 : 28. http://doi.acm.org/10.1145/3341709 Google Scholar
Digital Library
- Li-yao Xia, Yannick Zakowski, Paul He, Chung-Kil Hur, Gregory Malecha, Benjamin C. Pierce, and Steve Zdancewic. 2020. Interaction trees: representing recursive and impure programs in Coq. Proceedings of the ACM on Programming Languages 4, POPL ( 2020 ), 51 : 1-51 : 32. https://www.cis.upenn.edu/~stevez/papers/XZHH+20.pdfGoogle Scholar
- Yizhou Zhang and Andrew C. Myers. 2019. Abstraction-safe efect handlers via tunneling. Proceedings of the ACM on Programming Languages 3, POPL ( 2019 ), 5 : 1-5 : 29. http://www.cs.cornell.edu/andru/papers/tunnel-ef/tunnel-ef.pdfGoogle Scholar
Index Terms
A separation logic for effect handlers
Recommendations
Retrofitting effect handlers onto OCaml
PLDI 2021: Proceedings of the 42nd ACM SIGPLAN International Conference on Programming Language Design and ImplementationEffect handlers have been gathering momentum as a mechanism for modular programming with user-defined effects. Effect handlers allow for non-local control flow mechanisms such as generators, async/await, lightweight threads and coroutines to be ...
Effect handlers in scope
Haskell '14Algebraic effect handlers are a powerful means for describing effectful computations. They provide a lightweight and orthogonal technique to define and compose the syntax and semantics of different effects. The semantics is captured by handlers, which ...
First-class names for effect handlers
Algebraic effects and handlers are a promising technique for incorporating composable computational effects into functional programming languages. Effect handlers enable concisely programming with different effects, but they do not offer a convenient ...






Comments