Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

handlers

Source: /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/handlers.nix

Module Description

Effect handlers and middleware

Combinators

via

Applies a handler to an effect.

A handler is any function that transforms effects, typically Fx<A,U> -> Fx<B,V>. This combinator simply applies the handler, providing a named operation for documentation and readability.

Type Signature

(Fx<A,U> -> Fx<B,V>) -> Fx<A,U> -> Fx<B,V>

Parameters

  • handler: A function that transforms effects
  • e: The effect to handle

Example

# Apply a mapping handler
via (map (x: x + 1)) (pure 41)  # => Fx producing 42

# Chain multiple handlers
via (map toString) (via (map (x: x * 2)) (pure 21))

Notes

While via handler e is equivalent to handler e, using via makes the intent clearer and enables future middleware patterns.

See Also

  • map, contraMap - Common handlers
  • provide - Handler that eliminates requirements

Generated from /nix/store/mls72plk3raskl1r5afh3cl9ik3rn969-source/nix/handlers.nix