Skip to content

nfx

nfx brings structured algebraic effects to the Nix language. The kernel provides four primitives:

  1. immediate, an effect with a resolved value
  2. pending, an effect awaiting context
  3. adapt, transform context and continuation
  4. runFx, evaluate an effect once its requirements are satisfied

Everything else is derived from these.

  • Core system, kernel, basic (pure/value lifting), functor (map/contraMap), monad (mapM/flatMap/then’), provide (dependency injection), sequence (do-notation)
  • Context management, state threading, context, request capabilities, handlers, lens, pair, and, zip
  • Specialized effects, conditions (Common Lisp style resumable signals, handlers, restarts), result, bracket (guaranteed cleanup), rw (reader/writer), acc (accumulators), choice (non-deterministic backtracking), arrow

nfx is the algebraic-effects foundation for Nix. It underpins higher-level functional libraries in the ecosystem, composing naturally with pipe’s freer monad pipelines and powering stream and reactivity-oriented work like ned and zen. It is the Nix member of a cross-language effects family alongside fx.go and fx-rs.

Source Code Support this project