Abstract
Runners of algebraic effects, also known as comodels, provide a mathematical model of resource management. We show that they also give rise to a programming concept that models top-level external resources, as well as allows programmers to modularly define their own intermediate “virtual machines”. We capture the core ideas of programming with runners in an equational calculus \(\lambda _{\mathsf {coop}}\), which we equip with a sound and coherent denotational semantics that guarantees the linear use of resources and execution of finalisation code. We accompany \(\lambda _{\mathsf {coop}}\) with examples of runners in action, provide a prototype language implementation in OCaml, as well as a Haskell library based on \(\lambda _{\mathsf {coop}}\).
Chapter PDF
References
Ahman, D.: Library Haskell-Coop. Available at https://github.com/danelahman/haskell-coop (2019)
Ahman, D., Fournet, C., Hritcu, C., Maillard, K., Rastogi, A., Swamy, N.: Recalling a witness: foundations and applications of monotonic state. PACMPL 2(POPL), 65:1–65:30 (2018)
Bauer, A., Pretnar, M.: An effect system for algebraic effects and handlers. Logical Methods in Computer Science 10(4) (2014)
Bauer, A., Pretnar, M.: Programming with algebraic effects and handlers. J. Log. Algebr. Meth. Program. 84(1), 108–123 (2015)
Bauer, A.: What is algebraic about algebraic effects and handlers? CoRR abs/1807.05923 (2018)
Bauer, A.: Programming language coop. Available at https://github.com/andrejbauer/coop (2019)
Benton, N., Kennedy, A.: Exceptional syntax. Journal of Functional Programming 11(4), 395–410 (2001)
Delignat-Lavaud, A., Fournet, C., Kohlweiss, M., Protzenko, J., Rastogi, A., Swamy, N., Zanella-Beguelin, S., Bhargavan, K., Pan, J., Zinzindohoue, J.K.: Implementing and proving the tls 1.3 record layer. In: 2017 IEEE Symp. on Security and Privacy (SP). pp. 463–482 (2017)
Dolan, S., Eliopoulos, S., Hillerström, D., Madhavapeddy, A., Sivaramakrishnan, K.C., White, L.: Concurrent system programming with effect handlers. In: Wang, M., Owens, S. (eds.) Trends in Functional Programming. pp. 98–117. Springer International Publishing, Cham (2018)
Foster, J.N., Greenwald, M.B., Moore, J.T., Pierce, B.C., Schmitt, A.: Combinators for bidirectional tree transformations: A linguistic approach to the view-update problem. ACM Trans. Program. Lang. Syst. 29(3) (2007)
Hyland, M., Plotkin, G., Power, J.: Combining effects: Sum and tensor. Theor. Comput. Sci. 357(1–3), 70–99 (2006)
Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: Proc. of 18th ACM SIGPLAN Int. Conf. on Functional Programming, ICFP 2013. ACM (2013)
Katsumata, S., Rivas, E., Uustalu, T.: Interaction laws of monads and comonads. CoRR abs/1912.13477 (2019)
Kiselyov, O., Ishii, H.: Freer monads, more extensible effects. In: Proc. of 2015 ACM SIGPLAN Symp. on Haskell. pp. 94–105. Haskell ’15, ACM (2015)
Koopman, P., Fokker, J., Smetsers, S., van Eekelen, M., Plasmeijer, R.: Functional Programming in Clean. University of Nijmegen (1998), draft
Leijen, D.: Structured asynchrony with algebraic effects. In: Proceedings of the 2nd ACM SIGPLAN International Workshop on Type-Driven Development, TyDe@ICFP 2017, Oxford, UK, September 3, 2017. pp. 16–29. ACM (2017)
Leijen, D.: Algebraic effect handlers with resources and deep finalization. Tech. Rep. MSR-TR-2018-10, Microsoft Research (April 2018)
Leijen, D.: Programming with implicit values, functions, and control (or, implicit functions: Dynamic binding with lexical scoping). Tech. Rep. MSR-TR-2019-7, Microsoft Research (March 2019)
Levy, P.B.: Call-By-Push-Value: A Functional/Imperative Synthesis, Semantics Structures in Computation, vol. 2. Springer (2004)
Miltner, A., Maina, S., Fisher, K., Pierce, B.C., Walker, D., Zdancewic, S.: Synthesizing symmetric lenses. Proc. ACM Program. Lang. 3(ICFP), 95:1–95:28 (2019)
Møgelberg, R.E., Staton, S.: Linear usage of state. Logical Methods in Computer Science 10(1) (2014)
Moggi, E.: Computational lambda-calculus and monads. In: Proc. of 4th Ann. Symp. on Logic in Computer Science, LICS 1989. pp. 14–23. IEEE (1989)
Moggi, E.: Notions of computation and monads. Inf. Comput. 93(1), 55–92 (1991)
O’Connor, R.: Functor is to lens as applicative is to biplate: Introducing multiplate. CoRR abs/1103.2841 (2011)
Plotkin, G., Power, J.: Semantics for algebraic operations. In: Proc. of 17th Conf. on the Mathematical Foundations of Programming Semantics, MFPS XVII. ENTCS, vol. 45, pp. 332–345. Elsevier (2001)
Plotkin, G., Power, J.: Algebraic operations and generic effects. Appl. Categor. Struct. (1), 69–94 (2003)
Plotkin, G., Power, J.: Tensors of comodels and models for operational semantics. In: Proc. of 24th Conf. on Mathematical Foundations of Programming Semantics, MFPS XXIV. ENTCS, vol. 218, pp. 295–311. Elsevier (2008)
Plotkin, G.D., Power, J.: Notions of computation determine monads. In: Proc. of 5th Int. Conf. on Foundations of Software Science and Computation Structures, FOSSACS 2002. LNCS, vol. 2303, pp. 342–356. Springer (2002)
Plotkin, G.D., Pretnar, M.: A logic for algebraic effects. In: Proc. of 23th Ann. IEEE Symp. on Logic in Computer Science, LICS 2008. pp. 118–129. IEEE (2008)
Plotkin, G.D., Pretnar, M.: Handling algebraic effects. Logical Methods in Computer Science 9(4:23) (2013)
Power, J., Shkaravska, O.: From comodels to coalgebras: State and arrays. Electr. Notes Theor. Comput. Sci. 106, 297–314 (2004)
Power, J.: Enriched Lawvere theories. Theory Appl. Categ 6(7), 83–93 (1999)
Pretnar, M.: The Logic and Handling of Algebraic Effects. Ph.D. thesis, School of Informatics, University of Edinburgh (2010)
Saleh, A.H., Karachalias, G., Pretnar, M., Schrijvers, T.: Explicit effect subtyping. In: Proc. of 27th European Symposium on Programming, ESOP 2018. pp. 327–354. LNCS, Springer (2018)
Uustalu, T.: Stateful runners of effectful computations. Electr. Notes Theor. Comput. Sci. 319, 403–421 (2015)
Wadler, P.: The essence of functional programming. In: Sethi, R. (ed.) Proc. of 19th Ann. ACM SIGPLAN-SIGACT Symp. on Principles of Programming Languages, POPL 1992. pp. 1–14. ACM (1992)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Open Access This chapter is licensed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.
Copyright information
© 2020 The Author(s)
About this paper
Cite this paper
Ahman, D., Bauer, A. (2020). Runners in Action. In: Müller, P. (eds) Programming Languages and Systems. ESOP 2020. Lecture Notes in Computer Science(), vol 12075. Springer, Cham. https://doi.org/10.1007/978-3-030-44914-8_2
Download citation
DOI: https://doi.org/10.1007/978-3-030-44914-8_2
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-44913-1
Online ISBN: 978-3-030-44914-8
eBook Packages: Computer ScienceComputer Science (R0)