Abstract
Plotkin and Pretnar’s effect handlers offer a versatile abstraction for modular programming with user-defined effects. Traditional deep handlers are defined by folds over computation trees. In this paper we study shallow handlers, defined instead by case splits over computation trees. We show that deep and shallow handlers can simulate one another up to specific notions of administrative reduction. We present the first formal accounts of an abstract machine for shallow handlers and a Continuation Passing Style (CPS) translation for shallow handlers taking special care to avoid memory leaks. We provide implementations in the Links web programming language and empirically verify that neither implementation introduces unwarranted memory leaks.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Biernacki, D., Piróg, M., Polesiuk, P., Sieczkowski, F.: Handle with care: relational interpretation of algebraic effects and handlers. PACMPL 2(POPL), 8:1–8:30 (2018)
Cooper, E., Lindley, S., Wadler, P., Yallop, J.: Links: web programming without tiers. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2006. LNCS, vol. 4709, pp. 266–296. Springer, Heidelberg (2007). https://doi.org/10.1007/978-3-540-74792-5_12
Danvy, O., Nielsen, L.R.: A first-order one-pass CPS transformation. Theor. Comput. Sci. 308(1–3), 239–257 (2003)
Dolan, S., White, L., Sivaramakrishnan, K., Yallop, J., Madhavapeddy, A.: Effective concurrency through algebraic effects. In: OCaml Workshop (2015)
Felleisen, M., Friedman, D.P.: Control operators, the SECD-machine, and the \(\lambda \)-calculus. In: Formal Description of Programming Concepts III, pp. 193–217 (1987)
Flanagan, C., Sabry, A., Duba, B.F., Felleisen, M.: The essence of compiling with continuations. In: PLDI, pp. 237–247. ACM (1993)
Fokkinga, M.M.: Tupling and mutumorphisms. Squiggolist 1(4), 81–82 (1990)
Goodman, N.: Uber AI Labs open sources Pyro, a deep probabilistic programming language, November 2017. https://eng.uber.com/pyro/
Hillerström, D., Lindley, S.: Liberating effects with rows and handlers. In: TyDe@ICFP, pp. 15–27. ACM (2016)
Hillerström, D., Lindley, S.: Shallow effect handlers (extended version) (2018). http://homepages.inf.ed.ac.uk/slindley/papers/shallow-extended.pdf
Hillerström, D., Lindley, S., Atkey, R., Sivaramakrishnan, K.C.: Continuation passing style for effect handlers. In: FSCD. LIPIcs, vol. 84, pp. 18:1–18:19 (2017)
Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: ICFP, pp. 145–158. ACM (2013)
Kiselyov, O., Ishii, H.: Freer monads, more extensible effects. In: Haskell, pp. 94–105. ACM (2015)
Kiselyov, O., Sabry, A., Swords, C.: Extensible effects: an alternative to monad transformers. In: Haskell, pp. 59–70. ACM (2013)
Leijen, D.: Type directed compilation of row-typed algebraic effects. In: POPL, pp. 486–499. ACM (2017)
Levy, P.B., Power, J., Thielecke, H.: Modelling environments in call-by-value programming languages. Inf. Comput. 185(2), 182–210 (2003)
Lindley, S., McBride, C., McLaughlin, C.: Do be do be do. In: POPL, pp. 500–514. ACM (2017)
Meijer, E., Fokkinga, M., Paterson, R.: Functional programming with bananas, lenses, envelopes and barbed wire. In: Hughes, J. (ed.) FPCA 1991. LNCS, vol. 523, pp. 124–144. Springer, Heidelberg (1991). https://doi.org/10.1007/3540543961_7
Plotkin, G.D.: Call-by-name, call-by-value and the \(\lambda \)-calculus. Theor. Comput. Sci. 1(2), 125–159 (1975)
Plotkin, G., Power, J.: Adequacy for algebraic effects. In: Honsell, F., Miculan, M. (eds.) FoSSaCS 2001. LNCS, vol. 2030, pp. 1–24. Springer, Heidelberg (2001). https://doi.org/10.1007/3-540-45315-6_1
Plotkin, G.D., Pretnar, M.: Handling algebraic effects. Log. Methods Comput. Sci. 9(4), 1–36 (2013)
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. High.-Order Symb. Comput. 11(4), 363–397 (1998)
Wu, N., Schrijvers, T.: Fusion for free. In: Hinze, R., Voigtländer, J. (eds.) MPC 2015. LNCS, vol. 9129, pp. 302–322. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-19797-5_15
Yallop, J.: Staged generic programming. PACMPL 1(ICFP), 29:1–29:29 (2017)
Acknowledgements
We would like to thank John Longley for insightful discussions about the inter-encodings of deep and shallow handlers. Daniel Hillerström was supported by EPSRC grant EP/L01503X/1 (EPSRC Centre for Doctoral Training in Pervasive Parallelism). Sam Lindley was supported by EPSRC grant EP/K034413/1 (From Data Types to Session Types—A Basis for Concurrency and Distribution).
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2018 Springer Nature Switzerland AG
About this paper
Cite this paper
Hillerström, D., Lindley, S. (2018). Shallow Effect Handlers. In: Ryu, S. (eds) Programming Languages and Systems. APLAS 2018. Lecture Notes in Computer Science(), vol 11275. Springer, Cham. https://doi.org/10.1007/978-3-030-02768-1_22
Download citation
DOI: https://doi.org/10.1007/978-3-030-02768-1_22
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-02767-4
Online ISBN: 978-3-030-02768-1
eBook Packages: Computer ScienceComputer Science (R0)