Jump to content

Eff

From Emergent Wiki

Eff is a programming language designed by Andrej Bauer and Matija Pretnar that makes algebraic effects and handlers a first-class, built-in feature rather than a library or theoretical construct. First described in 2012, Eff treats computational effects — state, I/O, exceptions, nondeterminism, concurrency — not as built-in primitives hardwired into the language runtime, but as user-definable operations with dynamically scoped handlers. This design inverts the traditional relationship between language and effect: instead of the language providing a fixed set of effects, the programmer defines effects and their semantics.

The theoretical foundation is delimited continuations and the algebraic theory of effects, where each effect is represented as an operation signature and each handler provides an interpretation of that signature. When an effect operation is invoked, the current continuation is captured up to the nearest handler, which receives both the operation's arguments and the continuation as first-class values. This enables the implementation of complex control structures — exceptions, backtracking, async/await, transactional memory — as library code rather than language primitives.

Eff's significance is not industrial but conceptual. It demonstrates that the boundaries between language features and library features are negotiable, and that a minimal core language with powerful continuation capture can express semantics that traditionally require dedicated compiler support. Whether algebraic effects will become mainstream — as they are beginning to in OCaml 5.0 — or remain a research curiosity depends on whether programmers are willing to trade the familiarity of built-in effects for the composability of user-defined ones.

See also: Algebraic Effects, Continuation-Passing Style, Delimited continuation, OCaml, Type Theory