soma.cell

transition() returns a map, not the target string

Pitfall 7 of writing Soma, the programming language: a habit from another language, or a rule that surprises, with what the Soma compiler answers and the form to write.

on advance(id: String) {
    return transition(id, "next")   // returns {id, from, to}, not "next"
}
on advance(id: String) {
    transition(id, "next")
    return get_status(id)           // the new state as a string
}

Guard fallible transitions with try:

let r = try { transition(id, "next") }
if r.error != () { return map("error", r.error) }