This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 8/19/2026.
Taps
~import std/tapsKoru Standard Library: Event Taps
taps.kz · 1 tors · ~[comptime]
Koru Standard Library: Event Taps · 17 more lines
Koru Standard Library: Event Taps
Observe event transitions without touching the flow being observed.
A tap inserts a void call at the front of a matching continuation chain: the
bound value stays in scope, and the optimizer sees an ordinary step — so
observation lowers to a free, inline call rather than a runtime hook.
USAGE (in `.kz`):
import std/taps
// Observe a concrete source, bind its produced value, react:
tap(compute -> *): v |> observed(value: v)
// Metatype branch (required for wildcard sources):
tap(* -> *)
| Profile p |> profiler(p)
// TAP TRANSFORM
// When the compiler encounters tap(...), this transform:
// 1. Parses the source/destination patterns
// 2. Walks the program AST finding matching transitions
// 3. Wraps matching continuations with the tap's void call
// 4. Removes the tap declaration (it compiled away)
~[keyword|comptime|transform] pub tor tap {
expr: Expression,
invocation: *const Invocation,
item: *const Item,
program: *const Program,
allocator: std.mem.Allocator
} -> SiteResult