Skip to main content

Shallow Effect Handlers

  • Conference paper
  • First Online:
Book cover Programming Languages and Systems (APLAS 2018)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 11275))

Included in the following conference series:

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. 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)

    Google Scholar 

  2. 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

    Chapter  Google Scholar 

  3. Danvy, O., Nielsen, L.R.: A first-order one-pass CPS transformation. Theor. Comput. Sci. 308(1–3), 239–257 (2003)

    Article  MathSciNet  Google Scholar 

  4. Dolan, S., White, L., Sivaramakrishnan, K., Yallop, J., Madhavapeddy, A.: Effective concurrency through algebraic effects. In: OCaml Workshop (2015)

    Google Scholar 

  5. 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)

    Google Scholar 

  6. Flanagan, C., Sabry, A., Duba, B.F., Felleisen, M.: The essence of compiling with continuations. In: PLDI, pp. 237–247. ACM (1993)

    Google Scholar 

  7. Fokkinga, M.M.: Tupling and mutumorphisms. Squiggolist 1(4), 81–82 (1990)

    Google Scholar 

  8. Goodman, N.: Uber AI Labs open sources Pyro, a deep probabilistic programming language, November 2017. https://eng.uber.com/pyro/

  9. Hillerström, D., Lindley, S.: Liberating effects with rows and handlers. In: TyDe@ICFP, pp. 15–27. ACM (2016)

    Google Scholar 

  10. Hillerström, D., Lindley, S.: Shallow effect handlers (extended version) (2018). http://homepages.inf.ed.ac.uk/slindley/papers/shallow-extended.pdf

  11. 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)

    Google Scholar 

  12. Kammar, O., Lindley, S., Oury, N.: Handlers in action. In: ICFP, pp. 145–158. ACM (2013)

    Google Scholar 

  13. Kiselyov, O., Ishii, H.: Freer monads, more extensible effects. In: Haskell, pp. 94–105. ACM (2015)

    Google Scholar 

  14. Kiselyov, O., Sabry, A., Swords, C.: Extensible effects: an alternative to monad transformers. In: Haskell, pp. 59–70. ACM (2013)

    Google Scholar 

  15. Leijen, D.: Type directed compilation of row-typed algebraic effects. In: POPL, pp. 486–499. ACM (2017)

    Article  Google Scholar 

  16. Levy, P.B., Power, J., Thielecke, H.: Modelling environments in call-by-value programming languages. Inf. Comput. 185(2), 182–210 (2003)

    Article  MathSciNet  Google Scholar 

  17. Lindley, S., McBride, C., McLaughlin, C.: Do be do be do. In: POPL, pp. 500–514. ACM (2017)

    Google Scholar 

  18. 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

    Chapter  Google Scholar 

  19. Plotkin, G.D.: Call-by-name, call-by-value and the \(\lambda \)-calculus. Theor. Comput. Sci. 1(2), 125–159 (1975)

    Article  MathSciNet  Google Scholar 

  20. 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

    Chapter  Google Scholar 

  21. Plotkin, G.D., Pretnar, M.: Handling algebraic effects. Log. Methods Comput. Sci. 9(4), 1–36 (2013)

    Article  MathSciNet  Google Scholar 

  22. Reynolds, J.C.: Definitional interpreters for higher-order programming languages. High.-Order Symb. Comput. 11(4), 363–397 (1998)

    Article  Google Scholar 

  23. 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

    Chapter  Google Scholar 

  24. Yallop, J.: Staged generic programming. PACMPL 1(ICFP), 29:1–29:29 (2017)

    Google Scholar 

Download references

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

Authors

Corresponding author

Correspondence to Sam Lindley .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics