Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
126 tokens/sec
GPT-4o
47 tokens/sec
Gemini 2.5 Pro Pro
43 tokens/sec
o3 Pro
4 tokens/sec
GPT-4.1 Pro
47 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

On the Expressive Power of User-Defined Effects: Effect Handlers, Monadic Reflection, Delimited Control (1610.09161v2)

Published 28 Oct 2016 in cs.LO and cs.PL

Abstract: We compare the expressive power of three programming abstractions for user-defined computational effects: Bauer and Pretnar's effect handlers, Filinski's monadic reflection, and delimited control without answer-type-modification. This comparison allows a precise discussion about the relative expressiveness of each programming abstraction. It also demonstrates the sensitivity of the relative expressiveness of user-defined effects to seemingly orthogonal language features. We present three calculi, one per abstraction, extending Levy's call-by-push-value. For each calculus, we present syntax, operational semantics, a natural type-and-effect system, and, for effect handlers and monadic reflection, a set-theoretic denotational semantics. We establish their basic meta-theoretic properties: safety, termination, and, where applicable, soundness and adequacy. Using Felleisen's notion of a macro translation, we show that these abstractions can macro-express each other, and show which translations preserve typeability. We use the adequate finitary set-theoretic denotational semantics for the monadic calculus to show that effect handlers cannot be macro-expressed while preserving typeability either by monadic reflection or by delimited control. We supplement our development with a mechanised Abella formalisation.

Citations (73)

Summary

  • The paper’s main contribution is a systematic comparison using macro translations to assess the expressive power of user-defined effects.
  • It shows that monadic reflection and delimited control cannot express effect handlers while preserving typeability.
  • The analysis guides language design by illustrating how type-system features influence modular and type-safe effect abstractions.

Overview of Expressive Power of User-Defined Effects

The academic paper "On the Expressive Power of User-Defined Effects: Effect Handlers, Monadic Reflection, Delimited Control" offers a comprehensive comparison of three programming abstractions: effect handlers, monadic reflection, and delimited control without answer-type-modification. This comparison aids in evaluating the relative expressiveness of each abstraction and highlights the impact of seemingly unrelated language features on this expressiveness.

Effect handlers, introduced by Bauer and Pretnar, are built on algebraic effects and offer a modular structure for user-defined computational effects. The foundation here is the algebraic presentation of monadic models, allowing operations as syntactic constructs and handlers as a form of delimited control. The monadic reflection, attributed to Filinski, defines a calculus where user-defined monads stand independently, providing an abstract mechanism to manipulate effects through reflection and reification. Delimited control operators, like shift-zero and reset, enable sophisticated control-flow manipulation and are idealized as part of the continuation-passing-style (CPS) hierarchy.

The authors present three calculi, each extending Levy's call-by-push-value framework, to assess the expressive power. They introduce macro translations to compare the expressive power of the abstractions, showing inter-expressive relationships and examining typeability preservation. Notably, it is demonstrated that neither monadic reflection nor delimited control can macro-express effect handlers while preserving typeability, primarily due to the non-existence of a typeability-preserving translation from the calculus of effect handlers to the calculus of monadic reflection.

The implications of this research are multifaceted, influencing both programming language design and library implementation. Language designers face the challenge of selecting an abstraction that balances expressiveness and typeability. The paper's analysis also provides deeper insights into how certain type-system features, such as polymorphism, recursion, and more complex effect systems, can bridge gaps in expressiveness across these abstractions.

Further work suggested by the authors includes refining the calculi to explore extensions with additional type-system features, such as polymorphism and inductive types, to test if these could allow for typeability-preserving translations between the calculi. The exploration of global translations, which restrict the usage of reflection/shifts to a fixed set of primitives in each computation, presents another promising avenue for research.

In summary, this paper lays a robust foundation for analyzing user-defined effects in programming languages, with implications for the development of expressive, modular, and type-safe language implementations and libraries. As computational effects become increasingly pivotal in modern programming paradigms, this analysis is invaluable for advancing theoretical understanding and practical application.

Youtube Logo Streamline Icon: https://streamlinehq.com