soma.cell

Cell structure

Cell structure, in the reference of the Soma programming language (soma 3.2.4). A block marked ✓ is a whole program that soma check accepts; the others are excerpts.

As shown, this does not compile: soma check reports `value` exists only inside a memory `invariant` (the value / key being written, the slot's size) — in a handler use the local that holds it (E0011).

cell AppName {
    memory {
        data: Map<String, String> [persistent, consistent]    // → SQLite
        cache: Map<String, String> [ephemeral, local]         // → in-memory
    }

    state workflow {
        initial: draft
        draft -> review
        review -> approved
        review -> rejected
        * -> cancelled
    }

    every 30s {
        // runs periodically
    }

    after 5s {
        // runs once after delay (one-shot timer)
    }

    on handler_name(param1: Type, param2: Type) {
        // handler body
        return value
    }

    on request(method: String, path: String, body: String) {
        match path {
            "/" -> html(dashboard())
            "/api/data" -> get_data()
            _ -> response(404, map("error", "not found"))
        }
    }
}