Composable Effectful Computations in Rust: Integrating Algebraic Effects, Lenses, and Contextual Adaptation
fx-rs: An algebraic effects system for Rust.
Effect systems have become a powerful tool for structuring modular, composable, and type-safe effectful computations. While algebraic effects and handlers have seen widespread adoption in languages like Haskell and OCaml, their integration in Rust remains limited. We present Fx, a novel effect system for Rust that unifies algebraic effects, lenses, and contextual adaptation in a single, extensible abstraction. Fx enables ergonomic composition of effectful computations, modular interpretation via handlers, and fine-grained state manipulation using lenses. We demonstrate how Fx supports advanced patterns such as context adaptation and effectful accumulation, and evaluate its expressiveness and ergonomics through practical examples. Our work shows that Rust’s type system and ownership model can support advance