skip to main content

Effects for efficiency: asymptotic speedup with first-class control

Published:03 August 2020Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

Presentation at ICFP '20

References

  1. Andrej Bauer. 2018. What is algebraic about algebraic efects and handlers? CoRR abs/ 1807.05923 ( 2018 ).Google ScholarGoogle Scholar
  2. Andrej Bauer and Matija Pretnar. 2015. Programming with algebraic efects and handlers. J. Log. Algebr. Meth. Program. 84, 1 ( 2015 ), 108-123.Google ScholarGoogle Scholar
  3. 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 ScholarGoogle Scholar
  4. Nick Benton and Andrew Kennedy. 2001. Exceptional Syntax Journal of Functional Programming. J. Funct. Program. 11, 4 ( 2001 ), 395-410.Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Ulrich Berger. 1990. Totale Objekte und Mengen in der Bereichstheorie. Ph.D. Dissertation. Ludwig Maximillians-Universtität, Munich.Google ScholarGoogle Scholar
  6. Dariusz Biernacki, Maciej Piróg, Piotr Polesiuk, and Filip Sieczkowski. 2019. Abstracting algebraic efects. PACMPL 3, POPL ( 2019 ), 6 : 1-6 : 28.Google ScholarGoogle Scholar
  7. 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 ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. Richard S. Bird. 2006. Functional Pearl : A program to solve Sudoku. J. Funct. Program. 16, 6 ( 2006 ), 671-679.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Robert Cartwright and Matthias Felleisen. 1992. Observable Sequentiality and Full Abstraction. In POPL. ACM Press, 328-342.Google ScholarGoogle Scholar
  11. Lukas Convent, Sam Lindley, Conor McBride, and Craig McLaughlin. 2020. Doo bee doo bee doo. J. Funct. Program. 30 ( 2020 ). To appear.Google ScholarGoogle Scholar
  12. Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Cliford Stein. 2009. Introduction to Algorithms, Third Edition (3rd ed.). MIT Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle Scholar
  14. Olivier Danvy and Andrzej Filinski. 1990. Abstracting Control. In LISP and Functional Programming. ACM, 151-160.Google ScholarGoogle Scholar
  15. Stephen Dolan, Leo White, KC Sivaramakrishnan, Jeremy Yallop, and Anil Madhavapeddy. 2015. Efective Concurrency through Algebraic Efects. OCaml Workshop.Google ScholarGoogle Scholar
  16. Martín Hötzel Escardó. 2007. Infinite sets that admit fast exhaustive search. In LICS. IEEE Computer Society, 443-452.Google ScholarGoogle Scholar
  17. Kavon Farvardin and John H. Reppy. 2020. From folklore to fact: comparing implementations of stacks and continuations. In PLDI. ACM, 75-90.Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  19. Matthias Felleisen. 1988. The Theory and Practice of First-Class Prompts. In POPL. ACM Press, 180-190.Google ScholarGoogle Scholar
  20. Matthias Felleisen. 1991. On the expressive power of programming languages. Sci. Comput. Prog. 17, 1-3 ( 1991 ), 35-75.Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle Scholar
  22. Cormac Flanagan, Amr Sabry, Bruce F. Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In PLDI. ACM, 237-247.Google ScholarGoogle Scholar
  23. Matthew Flatt and R. Kent Dybvig. 2020. Compiler and runtime support for continuation marks. In PLDI. ACM, 45-58.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle Scholar
  25. Daniel Hillerström and Sam Lindley. 2016. Liberating efects with rows and handlers. In [email protected]. ACM, 15-27.Google ScholarGoogle Scholar
  26. Daniel Hillerström and Sam Lindley. 2018. Shallow Efect Handlers. In APLAS (Lecture Notes in Computer Science, Vol. 11275 ). Springer, 415-435.Google ScholarGoogle Scholar
  27. Daniel Hillerström, Sam Lindley, and Robert Atkey. 2020a. Efect handlers via generalised continuations. J. Funct. Program. 30 ( 2020 ), e5.Google ScholarGoogle Scholar
  28. 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 ScholarGoogle Scholar
  29. 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 ScholarGoogle Scholar
  30. John Hughes. 1986. A Novel Representation of Lists and its Application to the Function "reverse". Inf. Process. Lett. 22, 3 ( 1986 ), 141-144.Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Neil Jones. 2001. The expressive power of higher-order types, or, life without CONS. J. Funct. Program. 11 ( 2001 ), 5-94.Google ScholarGoogle Scholar
  32. Ohad Kammar, Sam Lindley, and Nicolas Oury. 2013. Handlers in action. In ICFP. ACM, 145-158.Google ScholarGoogle Scholar
  33. Oleg Kiselyov, Amr Sabry, and Cameron Swords. 2013. Extensible efects: an alternative to monad transformers. In Haskell. ACM, 59-70.Google ScholarGoogle Scholar
  34. Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. 2005. Backtracking, Interleaving, and Terminating Monad Transformers: (Functional Pearl). ( 2005 ), 192-203.Google ScholarGoogle Scholar
  35. Donald Knuth. 1997. The Art of Computer Programming, Volume 1 : Fundamental Algorithms (third edition). Addison-Wesley.Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Daan Leijen. 2017. Type directed compilation of row-typed algebraic efects. In POPL. ACM, 486-499.Google ScholarGoogle Scholar
  37. 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 ScholarGoogle Scholar
  38. Sam Lindley, Conor McBride, and Craig McLaughlin. 2017. Do be do be do. In POPL. ACM, 500-514.Google ScholarGoogle Scholar
  39. John Longley. 1999. When is a functional program not a functional program?. In ICFP. ACM, 1-7.Google ScholarGoogle Scholar
  40. John Longley. 2018. The recursion hierarchy for PCF is strict. Logical Methods in Comput. Sci. 14, 3 : 8 ( 2018 ), 1-51.Google ScholarGoogle Scholar
  41. John Longley. 2019. Bar recursion is not computable via iteration. Computability 8, 2 ( 2019 ), 119-153.Google ScholarGoogle Scholar
  42. John Longley and Dag Normann. 2015. Higher-Order Computability. Springer.Google ScholarGoogle Scholar
  43. Robin Milner. 1977. Fully Abstract Models of Typed λ-Calculi. Theor. Comput. Sci. 4, 1 ( 1977 ), 1-22.Google ScholarGoogle Scholar
  44. MLton. 2020. MLton website. http://www.mlton.orgGoogle ScholarGoogle Scholar
  45. Eugenio Moggi. 1991. Notions of Computation and Monads. Inf. Comput. 93, 1 ( 1991 ), 55-92.Google ScholarGoogle Scholar
  46. Chris Okasaki. 1999. Purely functional data structures. Cambridge University Press.Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. Nicholas Pippenger. 1996. Pure versus impure Lisp. In POPL. ACM, 104-109.Google ScholarGoogle Scholar
  48. 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 ScholarGoogle Scholar
  49. Gordon Plotkin. 1977. LCF considered as a programming language. Theor. Comput. Sci. 5, 3 ( 1977 ), 223-255.Google ScholarGoogle Scholar
  50. Gordon D. Plotkin and John Power. 2001. Adequacy for Algebraic Efects. In FoSSaCS (Lecture Notes in Computer Science, Vol. 2030 ). Springer, 1-24.Google ScholarGoogle Scholar
  51. Gordon D. Plotkin and Matija Pretnar. 2013. Handling Algebraic Efects. Logical Methods in Computer Science 9, 4 ( 2013 ).Google ScholarGoogle Scholar
  52. Matija Pretnar. 2015. An Introduction to Algebraic Efects and Handlers. Electr. Notes Theor. Comput. Sci. 319 ( 2015 ), 19-35. Invited tutorial paper.Google ScholarGoogle Scholar
  53. Dana Scott and Christopher Strachey. 1971. Proceedings of the Symposium on Computers and Automata 21 ( 1971 ).Google ScholarGoogle Scholar
  54. Alex K. Simpson. 1998. Lazy Functional Algorithms for Exact Real Functionals. In MFCS (Lecture Notes in Computer Science, Vol. 1450 ). Springer, 456-464.Google ScholarGoogle Scholar
  55. SML /NJ. 2020. SML/NJ website. http://www.smlnj.orgGoogle ScholarGoogle Scholar
  56. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Effects for efficiency: asymptotic speedup with first-class control

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Article Metrics

          • Downloads (Last 12 months)58
          • Downloads (Last 6 weeks)6

          Other Metrics

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!