← writing

the first monad

summary: the kernel signature on day one is the kernel signature today, even though the discipline around it changed.

RayforceDB Rayforce: restart in C for embeddability work: Feb-Aug 2023 technical note

Core idea: the first Rayfall primitive established the kernel signature and arity dispatch shape that later allocator and runtime work had to serve.

The first language primitive landed in February. The commit message read "introduce first monad". The function was til:

g0 til(i64 count) {
    i64 *vec = (i64 *)malloc(count * sizeof(i64));
    for (i64 i = 0; i < count; i++) vec[i] = i;
    return new_vector_i64(vec, count);
}

It calls malloc, which six months later it does not, and which six months later it will not. The buddy allocator and the slab cache I wrote since are in front of it. The discipline arrived after the kernel did, not before it.

What did arrive on day one and has not changed is the signature: g0 in, g0 out, one slot per (glyph, arity) in the dispatch table, the caller branches once on arity it already knows. Every monad I have added since has fit that shape. The discipline I had to learn; the shape I got right by writing it down before the runtime existed to argue with me.