CMU-CS-03-149
Computer Science Department
School of Computer Science, Carnegie Mellon University



CMU-CS-03-149

A Modal Calculus for Effect Handling

Aleksandar Nanevski

June 2003

CMU-CS-03-149.ps
CMU-CS-03-149.pdf


Keywords: Modal logic, effect systems, exceptions, composable continuations


In their purest formulation, monads are used in functional programming for two purposes: (1) to hygienically propagate effects, and (2) to globalize the effect scope -- once an effect occurs, the purity of the surrounding computation cannot be restored. As a consequence, monadic typing does not provide very naturally for the practically important ability to handle effects, and there is a number of previous works directed toward remedying this deficiency. It is mostly based on extending the monadic framework with further extra-logical constructs to support handling.

In this paper we adopt a different approach, founded on the observation of Pfenning and Davies that an abstract monad can be decomposed in terms of modal operators for possibility &lang⟩ and necessity Box. Our idea is to use the Box modality (which is a comonad) for hygienic propagation of effects, and leave the globalization of effects scope to &lang⟩.

Then the effects which admit a natural notion of handling can be encoded using &Box; since they are not global, there is no need to push them under &lang⟩.

Based on this idea, we develop a general framework for effect handling systems, and obtain novel calculi for exceptions, catch-and-throw and composable continuations as specific instantiations.

31 pages


Return to: SCS Technical Report Collection
School of Computer Science homepage

This page maintained by [email protected]