Affiliation:
1. University of Cambridge, UK
2. Tokyo Institute of Technology, Japan
3. Microsoft Research, USA
Abstract
Algebraic effects and handlers are a promising technique for incorporating composable computational effects into functional programming languages. Effect handlers enable concisely programming with different effects, but they do not offer a convenient way to program with different instances of the same effect. As a solution to this inconvenience, previous studies have introduced _named effect handlers_, which allow the programmer to distinguish among different effect instances. However, existing formalizations of named handlers are both involved and restrictive, as they employ non-standard mechanisms to prevent the escaping of handler names.
In this paper, we propose a simple and flexible design of named handlers. Specifically, we treat handler names as first-class values, and prevent their escaping while staying within the ordinary λ-calculus. Such a design is enabled by combining named handlers with _scoped effects_, a novel variation of effects that maintain a scope via rank-2 polymorphism. We formalize two combinations of named handlers and scoped effects, and implement them in the Koka programming language. We also present practical applications of named handlers, including a neural network and a unification algorithm.
Publisher
Association for Computing Machinery (ACM)
Subject
Safety, Risk, Reliability and Quality,Software
Reference50 articles.
1. Andrej Bauer and Matija Pretnar . 2014. An Effect System for Algebraic Effects and Handlers. Logical Methods in Computer Science, 10, 4 ( 2014 ). Andrej Bauer and Matija Pretnar. 2014. An Effect System for Algebraic Effects and Handlers. Logical Methods in Computer Science, 10, 4 (2014).
2. Programming with algebraic effects and handlers
3. Handle with care: relational interpretation of algebraic effects and handlers
4. Binders by day, labels by night: effect instances via lexically scoped handlers
Cited by
4 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. Abstracting Effect Systems for Algebraic Effect Handlers;Proceedings of the ACM on Programming Languages;2024-08-15
2. Soundly Handling Linearity;Proceedings of the ACM on Programming Languages;2024-01-05
3. Typed Equivalence of Labeled Effect Handlers and Labeled Delimited Control Operators;International Symposium on Principles and Practice of Declarative Programming;2023-10-22
4. Continuing WebAssembly with Effect Handlers;Proceedings of the ACM on Programming Languages;2023-10-16