Programming Languages

Compiling Effect Handlers in Capability-Passing Style

by Philipp Schuster, Jonathan Immanuel Brachthäuser, and Klaus Ostermann

In Proc. Int’l Conf. Functional Programming (ICFP). ACM Press, 2020.

This publication is related to the Effects research project.

Abstract

Effect handlers encourage programmers to abstract over repeated patterns of complex control flow. As of today, this abstraction comes at a significant price in performance. In this paper, we aim to achieve abstraction without regret for effect handlers. We present a language for effect handlers in _capability-passing style_ (lambda-cap) and an implementation of this language as a translation to simply-typed lambda calculus in _iterated continuation-passing style_. A suite of benchmarks indicates that the novel combination of capability-passing style and iterated CPS enables significant speedups over existing languages with effect handlers or control operators. Our implementation technique is general and allows us to generate code in any language that supports first-class functions. We then identify a subset of programs for which we can further improve the performance and guarantee full elimination of the effect handler abstraction. To formally capture this subset, we refine lambda-cap; to llambda-cap; with a more restrictive type system. We present a type-directed translation for llambda-cap; that inserts staging annotations and prove that no abstractions or applications related to effect handlers occur in the translated program. Using this second translation we observe additional speedups in some of the benchmarks.

News

Presentation at ICFP 2020

Philipp Schuster
Alumni
Philipp Schuster
presents the paper Compiling Effect Handlers in Capability-Passing Style at the International Conference on Functional Programming (ICFP) 2020 virtual event.

Read more ...

Related Publications

Zero-cost Effect Handlers by Staging (Technical Report)

by Philipp Schuster, Jonathan Immanuel Brachthäuser, and Klaus Ostermann

Technical report. University of Tübingen, Germany, 2019.

Learn More