Abstract
We study the fundamental efficiency of delimited control. Specifically, we show that effect handlers enable an asymptotic improvement in runtime complexity for a certain class of functions. We consider the generic count problem using a pure PCF-like base language λb and its extension with effect handlers λh.
We show that λh admits an asymptotically more efficient implementation of generic count than any λb implementation.
We also show that this efficiency gap remains when λb is extended with mutable state.
To our knowledge this result is the first of its kind for control operators.
Supplemental Material
- Andrej Bauer. 2018. What is algebraic about algebraic efects and handlers? CoRR abs/ 1807.05923 ( 2018 ).Google Scholar
- Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. J. Log. Algebr. Meth. Program. 84, 1 ( 2015 ), 108-123.Google Scholar
- Jordan Bell and Brett Stevens. 2009. A survey of known results and research areas for n-queens. Discret. Math. 309, 1 ( 2009 ), 1-31.Google Scholar
- Nick Benton and Andrew Kennedy. 2001. Exceptional Syntax Journal of Functional Programming. J. Funct. Program. 11, 4 ( 2001 ), 395-410.Google Scholar
Digital Library
- Ulrich Berger. 1990. Totale Objekte und Mengen in der Bereichstheorie. Ph.D. Dissertation. Ludwig Maximillians-Universtität, Munich.Google Scholar
- Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting algebraic efects. PACMPL 3, POPL ( 2019 ), 6 : 1-6 : 28.Google Scholar
- Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2020. Binders by day, labels by night: efect instances via lexically scoped handlers. PACMPL 4, POPL ( 2020 ), 48 : 1-48 : 29.Google Scholar
- Richard Bird, Geraint Jones, and Oege de Moor. 1997. More haste less speed: lazy versus eager evaluation. J. Funct. Program. 7, 5 ( 1997 ), 541-547.Google Scholar
Digital Library
- Richard S. Bird. 2006. Functional Pearl : A program to solve Sudoku. J. Funct. Program. 16, 6 ( 2006 ), 671-679.Google Scholar
Digital Library
- Robert Cartwright and Matthias Felleisen. 1992. Observable Sequentiality and Full Abstraction. In POPL. ACM Press, 328-342.Google Scholar
- Lukas Convent, Sam Lindley, Conor McBride, and Craig McLaughlin. 2020. Doo bee doo bee doo. J. Funct. Program. 30 ( 2020 ). To appear.Google Scholar
- Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliford Stein. 2009. Introduction to Algorithms, Third Edition (3rd ed.). MIT Press.Google Scholar
Digital Library
- Robbie Daniels. 2016. Eficient Generic Searches and Programming Language Expressivity. Master's thesis. School of Informatics, the University of Edinburgh, Scotland. http://homepages.inf.ed.ac.uk/jrl/Research/Robbie_Daniels_MSc_dissertation.pdfGoogle Scholar
- Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. ACM, 151-160.Google Scholar
- Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective Concurrency through Algebraic Efects. OCaml Workshop.Google Scholar
- Martín Hötzel Escardó. 2007. Infinite sets that admit fast exhaustive search. In LICS. IEEE Computer Society, 443-452.Google Scholar
- Kavon Farvardin and John H. Reppy. 2020. From folklore to fact: comparing implementations of stacks and continuations. In PLDI. ACM, 75-90.Google Scholar
Digital Library
- Matthias Felleisen. 1987. The Calculi of Lambda-nu-cs Conversion: A Syntactic Theory of Control and State in Imperative Higher-order Programming Languages. Ph.D. Dissertation. Indianapolis, IN, USA. AAI8727494.Google Scholar
Digital Library
- Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In POPL. ACM Press, 180-190.Google Scholar
- Matthias Felleisen. 1991. On the expressive power of programming languages. Sci. Comput. Prog. 17, 1-3 ( 1991 ), 35-75.Google Scholar
Digital Library
- Matthias Felleisen and Daniel P. Friedman. 1987. Control Operators, the SECD-machine, and the λ-Calculus. In The Proceedings of the Conference on Formal Description of Programming Concepts III, Ebberup, Denmark. Elsevier, 193-217.Google Scholar
- Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In PLDI. ACM, 237-247.Google Scholar
- Matthew Flatt and R. Kent Dybvig. 2020. Compiler and runtime support for continuation marks. In PLDI. ACM, 45-58.Google Scholar
Digital Library
- Yannick Forster, Ohad Kammar, Sam Lindley, and Matija Pretnar. 2019. On the expressive power of user-defined efects: Efect handlers, monadic reflection, delimited control. J. Funct. Program. 29 ( 2019 ), e15.Google Scholar
- Daniel Hillerström and Sam Lindley. 2016. Liberating efects with rows and handlers. In [email protected]. ACM, 15-27.Google Scholar
- Daniel Hillerström and Sam Lindley. 2018. Shallow Efect Handlers. In APLAS (Lecture Notes in Computer Science, Vol. 11275 ). Springer, 415-435.Google Scholar
- Daniel Hillerström, Sam Lindley, and Robert Atkey. 2020a. Efect handlers via generalised continuations. J. Funct. Program. 30 ( 2020 ), e5.Google Scholar
- Daniel Hillerström, Sam Lindley, Robert Atkey, and K. C. Sivaramakrishnan. 2017. Continuation Passing Style for Efect Handlers. In FSCD (LIPIcs, Vol. 84 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 18 : 1-18 : 19.Google Scholar
- Daniel Hillerström, Sam Lindley, and John Longley. 2020b. Efects for Eficiency: Asymptotic Speedup with First-Class Control (extended version). arXiv:2007. 00605 [cs.PL]Google Scholar
- John Hughes. 1986. A Novel Representation of Lists and its Application to the Function "reverse". Inf. Process. Lett. 22, 3 ( 1986 ), 141-144.Google Scholar
Digital Library
- Neil Jones. 2001. The expressive power of higher-order types, or, life without CONS. J. Funct. Program. 11 ( 2001 ), 5-94.Google Scholar
- Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In ICFP. ACM, 145-158.Google Scholar
- Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible efects: an alternative to monad transformers. In Haskell. ACM, 59-70.Google Scholar
- Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. 2005. Backtracking, Interleaving, and Terminating Monad Transformers: (Functional Pearl). ( 2005 ), 192-203.Google Scholar
- Donald Knuth. 1997. The Art of Computer Programming, Volume 1 : Fundamental Algorithms (third edition). Addison-Wesley.Google Scholar
Digital Library
- Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In POPL. ACM, 486-499.Google Scholar
- Paul Blain Levy, John Power, and Hayo Thielecke. 2003. Modelling environments in call-by-value programming languages. Inf. Comput. 185, 2 ( 2003 ), 182-210.Google Scholar
- Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do. In POPL. ACM, 500-514.Google Scholar
- John Longley. 1999. When is a functional program not a functional program?. In ICFP. ACM, 1-7.Google Scholar
- John Longley. 2018. The recursion hierarchy for PCF is strict. Logical Methods in Comput. Sci. 14, 3 : 8 ( 2018 ), 1-51.Google Scholar
- John Longley. 2019. Bar recursion is not computable via iteration. Computability 8, 2 ( 2019 ), 119-153.Google Scholar
- John Longley and Dag Normann. 2015. Higher-Order Computability. Springer.Google Scholar
- Robin Milner. 1977. Fully Abstract Models of Typed λ-Calculi. Theor. Comput. Sci. 4, 1 ( 1977 ), 1-22.Google Scholar
- MLton. 2020. MLton website. http://www.mlton.orgGoogle Scholar
- Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( 1991 ), 55-92.Google Scholar
- Chris Okasaki. 1999. Purely functional data structures. Cambridge University Press.Google Scholar
Digital Library
- Nicholas Pippenger. 1996. Pure versus impure Lisp. In POPL. ACM, 104-109.Google Scholar
- Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Typed Equivalence of Efect Handlers and Delimited Control. In FSCD (LIPIcs, Vol. 131 ). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik, 30 : 1-30 : 16.Google Scholar
- Gordon Plotkin. 1977. LCF considered as a programming language. Theor. Comput. Sci. 5, 3 ( 1977 ), 223-255.Google Scholar
- Gordon D. Plotkin and John Power. 2001. Adequacy for Algebraic Efects. In FoSSaCS (Lecture Notes in Computer Science, Vol. 2030 ). Springer, 1-24.Google Scholar
- Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ).Google Scholar
- Matija Pretnar. 2015. An Introduction to Algebraic Efects and Handlers. Electr. Notes Theor. Comput. Sci. 319 ( 2015 ), 19-35. Invited tutorial paper.Google Scholar
- Dana Scott and Christopher Strachey. 1971. Proceedings of the Symposium on Computers and Automata 21 ( 1971 ).Google Scholar
- Alex K. Simpson. 1998. Lazy Functional Algorithms for Exact Real Functionals. In MFCS (Lecture Notes in Computer Science, Vol. 1450 ). Springer, 456-464.Google Scholar
- SML /NJ. 2020. SML/NJ website. http://www.smlnj.orgGoogle Scholar
- Michael Sperber, Kent R. Dybvig, Matthew Flatt, Anton van Stratten, Robby Bruce Findler, and Jacob Matthews. 2009. Revised6 Report on the Algorithmic Language Scheme. J. Funct. Program. 19, S1 ( 2009 ), 1-301.Google Scholar
Digital Library
Index Terms
Effects for efficiency: asymptotic speedup with first-class control
Recommendations
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 ...
Effects as capabilities: effect handlers and lightweight effect polymorphism
Effect handlers have recently gained popularity amongst programming language researchers. Existing type- and effect systems for effect handlers are often complicated and potentially hinder a wide-spread adoption.
We present the language Effekt with ...
Handling bidirectional control flow
Pressed by the difficulty of writing asynchronous, event-driven code, mainstream languages have recently been building in support for a variety of advanced control-flow features. Meanwhile, experimental language designs have suggested effect handlers as ...






Comments