Home > lambdatheultimate > Handlers of Algebraic Effects

Handlers of Algebraic Effects

July 4th, 2010 07:54 admin Leave a comment Go to comments

Matija Pretnar, Gordon Plotkin (2009) Handlers of Algebraic Effects:

We present an algebraic treatment of exception handlers and,

more generally, introduce handlers for other computational effects repre-

sentable by an algebraic theory. These include nondeterminism, interac-

tive input/output, concurrency, state, time, and their combinations; in

all cases the computation monad is the free-model monad of the theory.

Each such handler corresponds to a model of the theory for the effects

at hand. The handling construct, which applies a handler to a compu-

tation, is based on the one introduced by Benton and Kennedy, and is

interpreted using the homomorphism induced by the universal property

of the free model. This general construct can be used to describe previ-

ously unrelated concepts from both theory and practice.

Handling a computational effect, such as raising an exception, amounts to homomorphically mapping the handled computation onto another computation. So, for example, raise is interpreted as the exception handling code given to the handler.

While encompassing both returning and non-returning handlers, this idea becomes more interesting when you start to handle the other effects, such as lookup and update. Then you can get things like state rollback when an exception occurs, and others (CSS renaming and hiding, stream redirection, timeout). Thus the semantics of handlers gives rise to a new programming construct.

If you want a gentler introduction to the subject (along with Plotkin's algebraic theory of effects and Levy's Call-by-Push-Value), try Pretnar's 2010 thesis.

Source: Handlers of Algebraic Effects

Related Articles:

  1. Programming with Algebraic Effects and Handlers
  2. Inferring algebraic effects
  3. Extensible Effects — An Alternative to Monad Transformers
  4. Extensible Effects — An Alternative to Monad Transformers
  5. Extensible Effects — An Alternative to Monad Transformers
blog comments powered by Disqus