Papers
Topics
Authors
Recent
Search
2000 character limit reached

Categorical Models of Effect Handlers

Updated 10 February 2026
  • Categorical models of effect handlers are algebraic frameworks that express, combine, and analyze computational effects using monads and equational theories.
  • They formalize effect handlers as algebra homomorphisms, ensuring soundness and completeness through universal categorical properties.
  • Recent developments extend these models to graded and scoped effects while integrating CPS semantics to handle complex effectful computations.

A categorical model of effect handlers provides a precise, algebraic foundation for expressing, combining, and analyzing computational effects and their deconstruction via handlers in programming languages. Grounded in the theory of monads, algebraic theories, and categorical semantics, these models accurately capture a wide range of effects—such as exceptions, state, nondeterminism, and I/O—through equational presentations, and give effect handlers the status of algebra homomorphisms, with rigorous universal properties, soundness, and completeness theorems. Recent developments include deep analyses of completeness, enrichment to handle scoped and graded effects, and the precise categorical characterization of both the canonical free-model and continuation-passing-style (CPS) semantics.

1. Signatures, Equational Theories, and the Algebraic Monad

An algebraic effect is specified by a signature Σ, a set of operation symbols op∈Op\mathit{op} \in \text{Op}, each with a parameter type AA and arity type BB, typically in Set\text{Set} or a suitable category. An equational theory TT over Σ consists of equations between Σ-terms, e.g., commutativity of choose\mathit{choose} for nondeterminism or read/write equations for state. The pair (Σ,T)(\Sigma,T) presents the algebraic theory of a computational effect (Plotkin et al., 2013, Bauer et al., 2012).

A Σ-algebra (a model of (Σ,T)(\Sigma,T)) is a set MM equipped with operations

$\op_M : A \times M^B \to M$

for each op:A→B\mathit{op}:A \to B, satisfying the equations of TT. The category of Σ-algebras, Mod(Σ,T)\mathsf{Mod}(\Sigma,T), and corresponding forgetful functor U:Mod(Σ,T)→SetU: \mathsf{Mod}(\Sigma,T) \to \text{Set}, admit a left adjoint F:Set→Mod(Σ,T)F:\text{Set} \to \mathsf{Mod}(\Sigma,T). The induced monad T:=U∘FT := U \circ F on Set\text{Set} consists of

ηX:X→TX,μX:T2X→TX\eta_X : X \to T X,\qquad \mu_X : T^2 X \to T X

satisfying the monad laws. Here, TXT X is the set of Σ-terms (i.e., computations) over XX, modulo the equations of TT (Plotkin et al., 2013, Bauer et al., 2012).

2. Effect Handlers as Algebra Homomorphisms

A (closed) effect handler with result type RR is a Σ-algebra structure on RR, i.e., for every operation op:A→B\mathit{op}:A \to B, a map

$\op_R : A \times R^B \to R$

that solves the theory TT. For any XX, any map f:X→Rf:X \to R extends uniquely to a Σ-homomorphism

♯f:FX→R\sharp f : F X \to R

making the following triangle commute: $\begin{diagram} X & \rTo^{\eta_X} & T X \ & \rdTo_{f} & \dDotsto_{\sharp f} \ & & R \end{diagram}$ In computational terms, ηX\eta_X is a pure computation, and ♯f\sharp f interprets the handling construct: for a computation in TXT X and a handler RR, ♯f\sharp f evaluates the computation under the handler, returning a value in RR (Plotkin et al., 2013, Bauer et al., 2012).

Handlers thus mediate between the free model (the syntax of computations) and models (instructions for deconstructing computations). The handler is uniquely determined by its behavior on variables and by satisfying the algebra laws—semantically, it is a homomorphism from the free Σ-algebra to the handler algebra (Bauer et al., 2012).

3. Soundness, Completeness, and the Equational Theory

For a programming language with algebraic effects and handlers, categorical models are formulated as strong monads (T,η,μ,str)(T, \eta, \mu, \mathsf{str}) on a cartesian category C\mathcal{C}, equipped with algebraic operation interpretations and a family of handler maps

handleΣ,Σ′,X:H(Σ,X)×TΣX→X\mathbf{handle}_{\Sigma, \Sigma', X}: \mathcal{H}(\Sigma, X) \times T_\Sigma X \to X

where H(Σ,X)\mathcal{H}(\Sigma, X) is the product of all handler-clause objects on XX.

The semantics must satisfy three core diagrams:

  • handle-unit: Handling a pure computation yields the value.
  • handle-mult: Handling the result of joining computations is the same as joining the handled results.
  • handle-op: Handling an operation processes it using the corresponding handler clause.

These directly correspond to the following equational laws on terms:

  • $\handlewithto{\return{V}}{H}{x}{N} = N[V/x]$
  • $\handlewithto{\mathsf{let}\;x=L\;\mathsf{in}\;M}{H}{y}{N} = \handlewithto{L}{H}{x}{\handlewithto{M}{H}{y}{N}}$
  • $\handlewithto{\mathit{op}(V)}{H}{x}{N} = M_\mathit{op}[V/x, \lambda v. N[v/x]/k]$

Soundness theorem: If M=NM = N is derivable in the equational theory, then their interpretations coincide in every categorical model of handlers.

Completeness theorem: If for all models, $\interpret{M} = \interpret{N}$, then M=NM=N is derivable in the theory (Kura, 3 Feb 2026).

These results demonstrate that the categorical structure, characterized by strong monads and handler maps satisfying the three diagrams, precisely captures the computation laws of effect handlers (Kura, 3 Feb 2026).

4. Variations: Graded, Scoped, and CPS Models

Category-Graded Algebraic Theories

Category-graded effect theories generalize algebraic signatures by indexing operations and equations over morphisms in a grading category SS (Sanada, 2022). In this setting:

  • An SS-graded signature Σ\Sigma has operations

σ:P→A;f∈Σ\sigma : P \to A; f \in \Sigma

with parameters, arities, and grades f:c→bf: c \to b.

  • Terms, operations, equations, and models are organized according to SS.
  • The free SS-graded monad $T^\TT$ is a lax functor Sop→[{ , }{ ] }S^{op} \to [\Set, \Set].
  • A handler is a lax natural transformation matching the grading structure, subject to algebra laws.

This captures effect systems where, for example, stateful protocols or effect dependencies follow categorical structure (e.g., session types) (Sanada, 2022).

Scoped (Functorial Algebra) Models

Effects with non-algebraic properties, such as delimited scopes, are modeled using pairs of functors Σ,Γ:C→C\Sigma, \Gamma : \mathcal{C}\to\mathcal{C} for algebraic and scoped operations, respectively (Yang et al., 2022). The resulting category of functorial algebras, built from the "grammar functor" GK=Id+ΣK+Γ(K∘K)G K = \text{Id} + \Sigma K + \Gamma(K\circ K), provides a categorical environment for both algebraic and scoped handlers. This model admits an adjunction L⊣RL \dashv R and comes with fusion laws for composing handlers, guaranteeing the modularity and compositionality of handler application (Yang et al., 2022).

Continuation-Passing-Style (CPS) Semantics

In addition to the canonical free-model monad semantics, categorical completeness theorems recognize the continuation-passing-style (CPS) model for effect handlers. In this model, computations are represented by types of the form

$D_\Sigma X = \forall \beta.\, (X \to \beta) \to \left(\prod_{\op \in \Sigma}(A_\op \times (B_\op \to \beta) \to \beta)\right) \to \beta$

with handling done by continuation-passing closure (Kura, 3 Feb 2026). This substantiates the expressiveness of CPS as a model of computational effects with handlers, not just free-model monads.

5. Examples and Modularity of Handlers

Concrete algebraic signatures model effects such as:

  • Exceptions: Nullary operations raisee:1→0\mathit{raise}_e:1\to 0 for each ee, leading to handlers as case analysis.
  • State: Operations like get:L→N\mathit{get}: L \to \mathbb{N}, set:L×N→1\mathit{set}:L\times\mathbb{N}\to 1; handlers encode state passing.
  • I/O: Operations read:1→Char\mathit{read}:1\to \text{Char}, write:Char→1\mathit{write}:\text{Char}\to 1; handlers structure side-effects such as logging.

Handlers for effect combinations are formed as coproducts (sum signatures), allowing effects to be combined and handled modularly. Handler composition corresponds to algebra homomorphism composition, supporting "stacking" of handlers (Plotkin et al., 2013).

The modular structure is made explicit in categories of functorial algebras and in the fusion laws of handler application (Yang et al., 2022). All handler constructions conform to the categorical universality property, ensuring uniform extensibility.

6. Contemporary Developments and Theoretical Scope

Recent work has formalized the full soundness and completeness of categorical models for handlers relative to syntactic calculi with algebraic effects and handlers (Kura, 3 Feb 2026). This result ensures that all models satisfying the core diagrams—including both classic free-model (Plotkin–Power) and CPS models—are valid for interpreting effectful programs with handlers.

Advancements in category-graded and scoped effect theories further generalize the expressivity of algebraic models. For example, CatEff’s grading by morphisms supports refined effect protocols and dependency tracking at the semantic level (Sanada, 2022). Functorial algebra models admit concise semantics for scope-delimiting effects, with equivalence results ensuring parity in expressive power with indexed and EM algebra models (Yang et al., 2022).

Categorical theorems such as the existence and uniqueness of handlers, their compositionality, and the duality of effect construction and deconstruction, are central structural results (Plotkin et al., 2013). The formalism accommodates variants—including those with stronger typing disciplines or modular effect systems—by varying the ambient category or the structure of the algebraic or graded theory.

7. Table: Summary of Categorical Models of Effect Handlers

Model Type Key Construction Notable References
Free-model monad Initial Σ-models via adjunction (Plotkin et al., 2013, Bauer et al., 2012)
Category-graded monad Lax functors Sop→[{ , }{ ] }S^{op} \to [\Set,\Set] (Sanada, 2022)
Functorial/scoped algebra Grammar endofunctor GG and adjunction L⊣RL\dashv R (Yang et al., 2022)
CPS semantics Polymorphic continuation objects DΣXD_\Sigma X (Kura, 3 Feb 2026)

The landscape of categorical models for effect handlers includes monadic, graded, and continuation-based approaches. All are governed by universal properties and categorical laws ensuring soundness and completeness, and they support modular reasoning about computations with algebraic and scope-delimited effects.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Categorical Models of Effect Handlers.