Programming Languages

Effekt: Lightweight Effect Polymorphism for Handlers

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

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

This publication is related to the Effekt: Algebraic Effect Handlers research project.

Abstract

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. In this paper, we present the language Effekt with the goal to close the gap between research languages with effect handlers and languages for working programmers. The design of Effekt revolves around a different view of effects and effect types. Traditionally, effect types express which _side effects_ a computation might have. In Effekt, effect types express which _capabilities_ a computation requires from its context. While this new point in the design space of effect systems impedes reasoning about the absence of effects, we demonstrate that it significantly simplifies the treatment of effect polymorphism and the related issues of effect parametricity and effect encapsulation. To guarantee effect safety, we separate functions from values and treat _all_ functions as second-class. We define the semantics of Effekt as a translation to System Xi, a calculus in explicit capability-passing style. We prove soundness of System Xi and of our translation. We present a full implementation together with an IDE integration helping programmers to understand the typing of effectful programs.