Asymptotic speedup via effect handlers

DANIEL HILLERSTRĂ–M,SAM LINDLEY,JOHN LONGLEY
DOI: https://doi.org/10.1017/s0956796824000030
2024-04-06
Journal of Functional Programming
Abstract:We study a fundamental efficiency benefit afforded by delimited control, showing that for certain higher-order functions, a language with advanced control features offers an asymptotic improvement in runtime over a language without them. Specifically, we consider the generic count problem in the context of a pure functional base language and an extension with general effect handlers. We prove that admits an asymptotically more efficient implementation of generic count than any implementation in . We also show that this gap remains even when is extended to a language with affine effect handlers, which is strong enough to encode exceptions, local state, coroutines and single-shot continuations. This locates the efficiency difference in the gap between 'single-shot' and 'multi-shot' versions of delimited control. To our knowledge, these results are the first of their kind for control operators.
computer science, software engineering
What problem does this paper attempt to address?