These libraries are experimental. APIs may change without notice. Generated from source with koruc 0.1.7 on 10/5/2026.

Flat

@korulang/flat@0.1.0

Fixed-capacity flat containers for Koru flow code — indexed i64/i32 arrays, borrowed-string ref tables, emit buffers, and the small algorithms flat storage enables (pair sort, run grouping, packed k-subsets)

flat/index.kz · 29 tors

@korulang/flat — fixed-capacity flat containers for flow code. · 26 more lines
@korulang/flat — fixed-capacity flat containers for flow code. The gap this fills: `std/list` is a growable list (push/get/pop) and `std/field` is a bit array — neither spells indexed set on a word cell, and nothing in std carries a string slice's address pair or an emit buffer. Algorithms that want flat, indexed, cache-dense storage had to write `|zig` leaves inline; this package is those leaves, generalized. Shapes, all obligation-tracked the same way (`live!` minted by `new`, discharged by `free` — the parse/close idiom): I64 / I32 fixed-capacity indexed integer cells (get/set/bump/add/zero) Refs string-slice table — packs a slice's ptr+len per slot so a borrowed string (e.g. a yyjson arena read) is storable in a flat structure without copying. The referenced memory must outlive the table's uses — this package stores addresses, not bytes. Buf byte emit buffer with JSON escaping (raw/jesc/closearr/done) Plus the small generic algorithms flat storage makes possible: pairs.sort sort parallel (key, payload) arrays by key runs.each yield each adjacent-equal-key run as {lo, hi} bounds combi.each yield every k-subset of an i64 range as a packed u64 key (8 bits per element — requires k <= 8 and ids <= 255) fail loud abort — std has no refuse-at-runtime tor

Phantom lifecycles

Derived from the phantom labels in the declarations below — state! issues an obligation the compiler will chase, !state discharges it, a bare state holds it without moving it. Nothing here is hand-drawn.

I64 1 state live!
I32 1 state live!
Refs 1 state live!
Buf 1 state live!

i64.new

<live!> index.kz:45

i64.get

<live> index.kz:55

i64.set

<live> index.kz:61

i64.bump

<live> index.kz:67

i64.add

<live> index.kz:73

i64.zero

<live> index.kz:79

i64.len

<live> index.kz:85

i64.free

<!live> index.kz:91

i32.new

<live!> index.kz:98

i32.get

<live> index.kz:108

i32.set

<live> index.kz:114

i32.len

<live> index.kz:120

i32.free

<!live> index.kz:126

ref.new

<live!> index.kz:145

ref.put

<live> index.kz:158

ref.str

<live> index.kz:165

ref.free

<!live> index.kz:172

buf.new

<live!> index.kz:192

buf.raw

<live> index.kz:200

buf.jesc

<live> index.kz:207

buf.closearr

<live> index.kz:242

buf.done

<live> index.kz:251

buf.free

<!live> index.kz:257

pairs.sort

<live> index.kz:269

runs.each

<live> index.kz:300

combi.each

<live> index.kz:339