soma.cell

Types and conversion builtins

10 builtins of Soma 3.2.4 in the category Types and conversion, with their exact signatures, as soma describe --builtins --json prints them.

len

len(x: String|List|Map) -> Int

Characters of a string, elements of a list, or entries of a map.

deterministic · replay: pure

Used in verified programs:

to_string

to_string(x) -> String

Render any value with its display formatting.

deterministic · replay: pure

Used in verified programs:

to_int

to_int(x) -> Int

Convert to Int (floats truncate, strings parse, BigInt-exact); returns () on failure.

deterministic · replay: pure

Used in verified programs:

to_float

to_float(x) -> Float

Convert to Float; returns () if a string fails to parse.

deterministic · replay: pure

Used in verified programs:

to_json

to_json(x) -> String

Serialize a value as JSON (strings escaped, NaN/inf become null).

deterministic · replay: pure

Used in verified programs:

from_json

from_json(s: String) -> Any

Parse a JSON string into a Map/List/scalar; maps and lists pass through. Invalid JSON RAISES (kind "json") — wrap LLM output in try { from_json(s) }.

deterministic · replay: pure

Used in verified programs:

type_of

type_of(x) -> String

Type name: "Int" (any size), "Float", "String", "Bool", "List", "Map", "Function", "Variant", or "Unit".

deterministic · replay: pure

Used in verified programs:

is_type

is_type(value: Map, type_name: String) -> Bool

True if a record's _type field equals type_name, or if value is a variant of that name or of the sum type of that name (is_a(Box { w: 1 }, "Box") and is_a(Box { w: 1 }, "Shape")); read a variant's fields with match.

deterministic · replay: pure

Used in verified programs:

is_a

is_a(value: Map, type_name: String) -> Bool

Alias of is_type.

deterministic · replay: pure

Used in verified programs:

fail

fail(kind: String, detail?) -> never | fail(r: TryResult) -> never

Raise a domain error. try { f() } yields {value, error, kind, detail}: branch on r.kind ("not_found", "invalid_transition", "guard_failed", "invariant", a require … else Tag tag, …); fail(r) re-raises a caught error unchanged.

deterministic · replay: pure

Used in verified programs: