{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,5,26]],"date-time":"2026-05-26T23:06:00Z","timestamp":1779836760714,"version":"3.53.1"},"reference-count":59,"publisher":"Cambridge University Press (CUP)","license":[{"start":{"date-parts":[[2020,3,16]],"date-time":"2020-03-16T00:00:00Z","timestamp":1584316800000},"content-version":"unspecified","delay-in-days":75,"URL":"https:\/\/www.cambridge.org\/core\/terms"}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["J. Funct. Prog."],"published-print":{"date-parts":[[2020]]},"abstract":"<jats:title>Abstract<\/jats:title>\n                  <jats:p>Plotkin and Pretnar\u2019s effect handlers offer a versatile abstraction for modular programming with user-defined effects. This paper focuses on foundations for implementing effect handlers, for the three different kinds of effect handlers that have been proposed in the literature: deep, shallow, and parameterised. Traditional deep handlers are defined by folds over computation trees and are the original construct proposed by Plotkin and Pretnar. Shallow handlers are defined by case splits (rather than folds) over computation trees. Parameterised handlers are deep handlers extended with a state value that is threaded through the folds over computation trees. We formulate the extensions both directly and via encodings in terms of deep handlers and illustrate how the direct implementations avoid the generation of unnecessary closures. We give two distinct foundational implementations of all the kinds of handlers we consider: a continuation-passing style (CPS) transformation and a CEK-style abstract machine. In both cases, the key ingredient is a generalisation of the notion of continuation to accommodate stacks of effect handlers. We obtain our CPS translation through a series of refinements as follows. We begin with a first-order CPS translation into untyped lambda calculus which manages a stack of continuations and handlers as a curried sequence of arguments. We then refine the initial CPS translation by uncurrying it to yield a properly tail-recursive translation and then moving towards more and more intensional representations of continuations in order to support different kinds of effect handlers. Finally, we make the translation higher order in order to contract administrative redexes at translation time. Our abstract machine design then uses the same generalised continuation representation as the CPS translation. We have implemented both the abstract machine and the CPS transformation (plus extensions) as backends for the Links web programming language.<\/jats:p>","DOI":"10.1017\/s0956796820000040","type":"journal-article","created":{"date-parts":[[2020,3,16]],"date-time":"2020-03-16T02:50:55Z","timestamp":1584327055000},"source":"Crossref","is-referenced-by-count":24,"title":["Effect handlers via generalised continuations"],"prefix":"10.1017","volume":"30","author":[{"ORCID":"https:\/\/orcid.org\/0000-0003-4730-9315","authenticated-orcid":false,"given":"DANIEL","family":"HILLERSTR\u00d6M","sequence":"first","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"SAM","family":"LINDLEY","sequence":"additional","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]},{"given":"ROBERT","family":"ATKEY","sequence":"additional","affiliation":[],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"56","published-online":{"date-parts":[[2020,3,16]]},"reference":[{"key":"S0956796820000040_ref59","first-page":"1","article-title":"Staged generic programming","volume":"1","author":"Yallop","year":"2017","journal-title":"PACMPL"},{"key":"S0956796820000040_ref58","doi-asserted-by":"publisher","DOI":"10.1145\/2633357.2633358"},{"key":"S0956796820000040_ref56","first-page":"24","article-title":"Monads for functional programming","volume":"925","author":"Wadler","year":"1995","journal-title":"Computer Science"},{"key":"S0956796820000040_ref53","unstructured":"Remy, D. (1993). Syntactic Theories and the Algebra of Record Terms. Technical report RR-1869. INRIA."},{"key":"S0956796820000040_ref52","doi-asserted-by":"publisher","DOI":"10.1016\/j.entcs.2015.12.003"},{"key":"S0956796820000040_ref51","doi-asserted-by":"publisher","DOI":"10.2168\/LMCS-9(4:23)2013"},{"key":"S0956796820000040_ref48","unstructured":"Pir\u00f3g, M. , Polesiuk, P. & Sieczkowski, F. (2019) Typed equivalence of effect handlers and delimited control. In FSCD. LIPIcs, vol. 131. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, pp. 30:1\u201330:16."},{"key":"S0956796820000040_ref22","doi-asserted-by":"publisher","DOI":"10.1145\/155090.155113"},{"key":"S0956796820000040_ref20","doi-asserted-by":"crossref","first-page":"687","DOI":"10.1017\/S0956796807006259","article-title":"A monadic framework for delimited continuations","volume":"17","author":"Dybvig","year":"2007","journal-title":"J. Funct. Program."},{"key":"S0956796820000040_ref1","volume-title":"Compiling with Continuations","author":"Appel","year":"1992"},{"key":"S0956796820000040_ref7","doi-asserted-by":"publisher","DOI":"10.2307\/1967631"},{"key":"S0956796820000040_ref17","first-page":"98","article-title":"Concurrent system programming with effect handlers","volume":"10788","author":"Dolan","year":"2017","journal-title":"Computer Science"},{"key":"S0956796820000040_ref16","doi-asserted-by":"publisher","DOI":"10.1016\/S0304-3975(02)00733-8"},{"key":"S0956796820000040_ref55","unstructured":"Steele, G. (1978) RABBIT: A Compiler for SCHEME. Technical report. AITR-474. INRIA."},{"key":"S0956796820000040_ref14","doi-asserted-by":"publisher","DOI":"10.1145\/91556.91622"},{"key":"S0956796820000040_ref18","unstructured":"Dolan, S. , White, L. & Madhavapeddy, A. (2014) Multicore OCaml. In OCaml Workshop."},{"key":"S0956796820000040_ref54","doi-asserted-by":"publisher","DOI":"10.1007\/s10990-007-9010-4"},{"key":"S0956796820000040_ref38","doi-asserted-by":"publisher","DOI":"10.1145\/13310.13333"},{"key":"S0956796820000040_ref19","unstructured":"Dolan, S. , White, L. , Sivaramakrishnan, K. C. , Yallop, J. & Madhavapeddy, A. (2015) Effective concurrency through algebraic effects. In OCaml Workshop."},{"key":"S0956796820000040_ref41","doi-asserted-by":"publisher","DOI":"10.1145\/3122975.3122977"},{"key":"S0956796820000040_ref3","doi-asserted-by":"publisher","DOI":"10.1023\/A:1020891112409"},{"key":"S0956796820000040_ref57","first-page":"302","article-title":"Fusion for free - efficient algebraic effect handlers","volume":"9129","author":"Wu","year":"2015","journal-title":"Computer Science"},{"key":"S0956796820000040_ref50","first-page":"1","volume-title":"In FoSSaCS. LNCS","volume":"2030","author":"Plotkin","year":"2001"},{"key":"S0956796820000040_ref33","unstructured":"James, R. P. & Sabry, A. (2011) Yield: Mainstream delimited continuations. In TPDC."},{"key":"S0956796820000040_ref34","doi-asserted-by":"publisher","DOI":"10.1145\/2500365.2500590"},{"key":"S0956796820000040_ref4","first-page":"1","article-title":"Handle with care: Relational interpretation of algebraic effects and handlers","volume":"2","author":"Biernacki","year":"2018","journal-title":"PACMPL"},{"key":"S0956796820000040_ref39","doi-asserted-by":"publisher","DOI":"10.4204\/EPTCS.153.8"},{"key":"S0956796820000040_ref12","doi-asserted-by":"crossref","unstructured":"Convent, L. , Lindley, S. , McBride, C. & McLaughlin, C. (to appear) Doo bee doo bee doo. J. Funct. Program. 30.","DOI":"10.1017\/S0956796820000039"},{"key":"S0956796820000040_ref2","first-page":"108","article-title":"Programming with algebraic effects and handlers","volume":"84","author":"Bauer","year":"2015","journal-title":"J. Log. Alg. Meth. Program."},{"key":"S0956796820000040_ref5","first-page":"1","article-title":"Abstracting algebraic effects","volume":"3","author":"Biernacki","year":"2019","journal-title":"PACMPL"},{"key":"S0956796820000040_ref49","doi-asserted-by":"publisher","DOI":"10.1016\/0304-3975(75)90017-1"},{"key":"S0956796820000040_ref21","unstructured":"Felleisen, M. & Friedman, D. P. (1987) Control operators, the SECD-machine, and the \u03bb-calculus. In Formal Description of Programming Concepts III, Wirsing, Martin (ed). Elsevier, pp. 193\u2013217."},{"key":"S0956796820000040_ref10","doi-asserted-by":"crossref","unstructured":"Brachth\u00e4user, J. I. , Schuster, P. & Ostermann, K. (to appear) Effekt: Capability-passing style for type- and effect-safe, extensible effect handlers in Scala. J. Funct. Program. 30.","DOI":"10.1017\/S0956796820000027"},{"key":"S0956796820000040_ref11","doi-asserted-by":"publisher","DOI":"10.1145\/231379.231395"},{"key":"S0956796820000040_ref47","first-page":"124","article-title":"Functional programming with bananas, lenses, envelopes and barbed wire","volume":"523","author":"Meijer","year":"1991","journal-title":"Computer Science"},{"key":"S0956796820000040_ref6","unstructured":"Bingham, E. , Chen, J. P. , Jankowiak, M. , Obermeyer, F. , Pradhan, N. , Karaletsos, T. , Singh, R. , Szerlip, P. , Horsfall, P. & Goodman, N. D. (2018) Pyro: Deep universal probabilistic programming. J. Mach. Learn. Res, 28:1\u201328:6."},{"key":"S0956796820000040_ref9","first-page":"1","article-title":"Effect handlers for the masses","volume":"2","author":"Brachth\u00e4user","year":"2018","journal-title":"PACMPL"},{"key":"S0956796820000040_ref44","doi-asserted-by":"publisher","DOI":"10.1145\/3009837.3009897"},{"key":"S0956796820000040_ref45","first-page":"296","volume-title":"In APLAS. LNCS","volume":"7705","author":"Materzok","year":"2012"},{"key":"S0956796820000040_ref13","first-page":"266","volume-title":"In FMCO. LNCS","volume":"4709","author":"Cooper","year":"2006"},{"key":"S0956796820000040_ref40","first-page":"339","article-title":"Implementing algebraic effects in C - \u201cmonads for free in C\u201d. In APLAS. Lecture Notes in","volume":"10695","author":"Leijen","year":"2017","journal-title":"Computer Science"},{"key":"S0956796820000040_ref23","first-page":"81","article-title":"Tupling and mutumorphisms","volume":"1","author":"Fokkinga","year":"1990","journal-title":"Squiggolist"},{"key":"S0956796820000040_ref26","unstructured":"Hillerstr\u00f6m, D. (2015) Handlers for Algebraic Effects in Links. MSc thesis, The University of Edinburgh, Scotland."},{"key":"S0956796820000040_ref24","first-page":"e15","article-title":"On the expressive power of user-defined effects: Effect handlers, monadic reflection, delimited control","volume":"1","author":"Forster","year":"2017","journal-title":"PACMPL"},{"key":"S0956796820000040_ref27","volume-title":"MSc(R) thesis","author":"Hillerstr\u00f6m","year":"2016"},{"key":"S0956796820000040_ref28","doi-asserted-by":"publisher","DOI":"10.1145\/2976022.2976033"},{"key":"S0956796820000040_ref35","doi-asserted-by":"publisher","DOI":"10.1145\/1291151.1291179"},{"key":"S0956796820000040_ref15","doi-asserted-by":"publisher","DOI":"10.1017\/S0960129500001535"},{"key":"S0956796820000040_ref29","first-page":"415","volume-title":"In APLAS","volume":"11275","author":"Hillerstr\u00f6m","year":"2018"},{"key":"S0956796820000040_ref36","doi-asserted-by":"publisher","DOI":"10.1016\/j.tcs.2012.02.025"},{"key":"S0956796820000040_ref30","unstructured":"Hillerstr\u00f6m, D. , Lindley, S. , Atkey, R. & Sivaramakrishnan, K. C. (2017) Continuation passing style for effect handlers. In FSCD. LIPIcs, vol. 84. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, pp. 18:1\u201318:19."},{"key":"S0956796820000040_ref8","doi-asserted-by":"publisher","DOI":"10.1145\/3136000.3136007"},{"key":"S0956796820000040_ref43","doi-asserted-by":"publisher","DOI":"10.1016\/S0890-5401(03)00088-9"},{"key":"S0956796820000040_ref31","unstructured":"Hillerstr\u00f6m, D. , Lindley, S. & Sivaramakrishnan, K. C. (2016) Compiling Links effect handlers to the OCaml backend. In ML Workshop."},{"key":"S0956796820000040_ref42","doi-asserted-by":"publisher","DOI":"10.1145\/3093333.3009872"},{"key":"S0956796820000040_ref32","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796897002864"},{"key":"S0956796820000040_ref25","doi-asserted-by":"publisher","DOI":"10.1017\/S0956796819000121"},{"key":"S0956796820000040_ref37","unstructured":"Kiselyov, O. & Sivaramakrishnan, K. C. (2016) Eff directly in OCaml. In ML Workshop."},{"key":"S0956796820000040_ref46","unstructured":"McBride, C. (2016) Shonky. https:\/\/github.com\/pigworker\/shonky."}],"container-title":["Journal of Functional Programming"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.cambridge.org\/core\/services\/aop-cambridge-core\/content\/view\/S0956796820000040","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,5,26]],"date-time":"2026-05-26T22:36:50Z","timestamp":1779835010000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.cambridge.org\/core\/product\/identifier\/S0956796820000040\/type\/journal_article"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2020]]},"references-count":59,"alternative-id":["S0956796820000040"],"URL":"https:\/\/doi.org\/10.1017\/s0956796820000040","relation":{},"ISSN":["0956-7968","1469-7653"],"issn-type":[{"value":"0956-7968","type":"print"},{"value":"1469-7653","type":"electronic"}],"subject":[],"published":{"date-parts":[[2020]]},"article-number":"e5"}}