A Calculus for Scoped Effects Handlers

04/19/2023
by   Roger Bosman, et al.
0

Algebraic effects handlers have become a standard approach for side-effects in functional programming. Their modular composition with other effects and clean separation of syntax and semantics make them attractive to a wide audience. However, not all effects can be classified as algebraic; some need a more sophisticated handling. In particular, effects that have or create a delimited scope need special care, as their continuation consists of two parts-in and out of the scope-and their modular composition introduces additional complexity. These effects are called scoped and have gained attention by their growing applicability and adoption in popular libraries. While calculi have been designed with algebraic effects handlers built in to facilitate their use, a calculus that supports scoped effects handlers in a similar manner does not yet exist. This work fills this gap: we present λ_𝑠𝑐, a calculus with native support for both algebraic and scoped effects handlers. It addresses the need for polymorphic handlers and explicit clauses for forwarding unknown scoped operations to other handlers. Our calculus is based on Eff, an existing calculus for algebraic effects, extended with Koka-style row polymorphism, and consists of a formal grammar, operational semantics, a (type-safe) type-and-effect system and type inference. We demonstrate λ_𝑠𝑐 on a range of examples.

READ FULL TEXT

page 11

page 13

page 15

research
11/18/2018

Handling polymorphic algebraic effects

Algebraic effects and handlers are a powerful abstraction mechanism to r...
research
03/04/2021

Contextual Modal Types for Algebraic Effects and Handlers

Programming languages with algebraic effects often rely on effect annota...
research
10/14/2022

When programs have to watch paint dry

We explore type systems and programming abstractions for the safe use of...
research
05/28/2020

Explicit Effect Subtyping

As popularity of algebraic effects and handlers increases, so does a dem...
research
12/31/2018

Eff Directly in OCaml

The language Eff is an OCaml-like language serving as a prototype implem...
research
08/25/2021

Latent Effects for Reusable Language Components: Extended Version

The development of programming languages can be quite complicated and co...
research
01/25/2022

Structured Handling of Scoped Effects: Extended Version

Algebraic effects offer a versatile framework that covers a wide variety...

Please sign up or login with your details

Forgot password? Click here to reset