[Paper Review] Eff Directly in OCaml
This paper presents a systematic, lightweight embedding of the Eff language—featuring algebraic effects and handlers—into OCaml using delimited continuations via the delimcc library or multicore OCaml. The authors demonstrate that dynamic effects, such as reference cells, are naturally supported as first-class effects without special syntax, and provide a novel direct denotational semantics for multi-prompt delimited control, proving the correctness of the embedding through tagless-final style interpretation.
The language Eff is an OCaml-like language serving as a prototype implementation of the theory of algebraic effects, intended for experimentation with algebraic effects on a large scale. We present the embedding of Eff into OCaml, using the library of delimited continuations or the multicore OCaml branch. We demonstrate the correctness of the embedding denotationally, relying on the tagless-final-style interpreter-based denotational semantics, including the novel, direct denotational semantics of multi-prompt delimited control. The embedding is systematic, lightweight, performant and supports even higher-order, 'dynamic' effects with their polymorphism. OCaml thus may be regarded as another implementation of Eff, broadening the scope and appeal of that language.
Motivation & Objective
- To embed the Eff language into standard and multicore OCaml using delimited control libraries.
- To demonstrate that dynamic effects—such as references—do not require special semantics but are naturally expressible as ordinary effects.
- To formalize a direct, non-continuation-passing-style denotational semantics for multi-prompt delimited control.
- To prove the correctness of the embedding using tagless-final style interpreter-based semantics.
- To show that the OCaml embedding enables practical, performant, and polymorphic effect handling with full support for higher-order effects.
Proposed method
- Using the delimcc library or multicore OCaml branch to implement delimited control primitives for effect handling.
- Translating Eff effect declarations and handlers into equivalent OCaml code using local, syntax-directed translation.
- Employing tagless-final style interpreter-based denotational semantics to formally model both Eff and delimited control.
- Introducing a novel direct denotational semantics for multi-prompt delimited control that avoids continuation-passing style.
- Proving the meaning-preserving nature of the translation via formal semantic equivalence between Eff and its OCaml embedding.
- Demonstrating that dynamic effect creation is expressible via standard effect operations, not requiring special treatment.
Experimental results
Research questions
- RQ1Can Eff be embedded into OCaml using standard libraries like delimcc or multicore OCaml while preserving full semantics and performance?
- RQ2Is the distinction between static and dynamic effects in Eff truly necessary, or can dynamic effects be modeled as ordinary effects?
- RQ3Can a direct, non-continuation-passing-style denotational semantics be formulated for multi-prompt delimited control?
- RQ4Does the embedding preserve type safety and polymorphism, especially for higher-order effects?
- RQ5Can the same formal semantics used for Eff be applied to the OCaml embedding to prove correctness?
Key findings
- The embedding of Eff into OCaml is systematic, lightweight, and supports higher-order and polymorphic effects without special syntax.
- Dynamic effects such as references are not a separate language feature but are expressible as ordinary effects, eliminating the need for special treatment.
- The authors successfully define a direct denotational semantics for multi-prompt delimited control that avoids continuation-passing style and meta-continuations.
- The correctness of the translation is formally proven using tagless-final style interpreter-based semantics.
- Performance benchmarks show the OCaml-embedded Eff is competitive with Eff’s own optimizing compiler.
- The approach enables practical use of algebraic effects in standard OCaml and inspires further embeddings, such as into F#.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.