A modal calculus for effect handling

Aleksandar Nanevski
2018
Abstract: "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
more » ... g 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 [diamond] and necessity [square]. Our idea is to use the [square] modality (which is a comonad) for hygienic propagation of effects, and leave the globalization of effect scope to [diamond]. Then the effects which admit a natural notion of handling can be encoded using [square]; since they are not global, there is no need to push them under [diamond]. 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."
doi:10.1184/r1/6591038 fatcat:daaqgwklbnck5bo5rqsasvnsha