ned Primitives
Overview
Section titled “Overview”ned is the stream-cycle library that dnzl builds on. Access it via dnzl.ned:
inherit (dnzl.ned) st run static-d map-c when-c;Stream constructor. Takes variadic arguments and returns a ST:
st 1 2 3 # ST [1 2 3]st "a" "b" # ST ["a" "b"]st # ST [] (empty stream when called with no args — use st.fromList [] or st with no application)st.fromList
Section titled “st.fromList”Convert a Nix list to a stream:
st.fromList [ 1 2 3 ] # ST [1 2 3]st.flatten
Section titled “st.flatten”Flatten a stream of streams one level:
st.flatten (st (st 1 2) (st 3 4)) # ST [1 2 3 4]Entry point for driving a cycle-c:
run : { inbox: ST, ... } → cycle-c → { outbox: ST, states: ST, ... }result = run { inbox = static-d [ "inc" "inc" "get" ]; } counter-c;result.outbox.toListstatic-d
Section titled “static-d”Convert a Nix list to a ST for use as an inbox driver:
static-d [ "inc" "inc" "get" ] # ST ["inc" "inc" "get"]Equivalent to st.fromList in most contexts. The -d suffix indicates it is a driver (input side).
Map a function over a stream — cycle-c form:
map-c f stream # equivalent to stream (st.map f)doubled = map-c (x: x * 2) (st 1 2 3);doubled.toList # [2 4 6]when-c
Section titled “when-c”Filter and transform a stream — content-based routing:
when-c pred stream f# → stream filtered to elements where pred holds, then mapped with fcounts = counter-c { inbox = when-c (m: m.type == "count") inbox (m: m.cmd);};Messages where m.type == "count" are extracted, mapped to m.cmd, and passed to counter-c.
scope-d
Section titled “scope-d”Scope a driver to a sub-key. Used for partitioning composite inboxes.
Context-aware stream. Lets a stream reference the surrounding ned context. Used for advanced wiring where cycles need access to the global run context.