[ AxiomCore · Documentation ]
Standard library
The acore modules, built-in functions and value members that the Axiom CLI 0.149.1 evaluator actually provides.
The Acore standard library is deliberately small. This page lists the acore:
modules the resolver returns, the built-in functions every module can call, and
the members you can use on strings, numbers and collections. Every entry was
evaluated with axiom eval from CLI 0.149.1; members that are declared but not
implemented are listed separately so you do not depend on them.
Modules
Import a module with its acore: URI. import makes the module's top-level
properties available by name; it does not create a math or json namespace.
import "acore:xml"
renderer = Renderer { indent = " " }| URI | Contents | Usable in 0.149.1 |
|---|---|---|
acore:base | Core value classes, collections, Regex, Duration, DataSize, and the Axiom contract schema classes | Loaded automatically into every module, so its classes need no import. |
acore:math | Declares min, max, sqrt, log, e and pi | No. The declarations have no native binding, so the names are undefined after import. |
acore:json | Declares parse(source: String): Any | No native binding |
acore:yaml | Declares parse(source: String): Any | No native binding |
acore:xml | Renderer { indent = " ", rootElementName = "root" } | Yes, as a configuration class |
acore:protobuf | Renderer { indent = " " } | Yes, as a configuration class |
acore:Project | Package { name, baseUri, version, packageZipUrl } and Dependency { uri } | Yes. Used by Acore project resolution. |
Any other acore: URI fails with Stdlib not found. The language source also
contains definitions for semantic versions, shell escaping, test helpers,
platform and release metadata, benchmarking, reflection and more renderers.
The resolver does not return them, so they are not a supported import surface.
Built-in functions
| Function | Result |
|---|---|
throw(value) | Stops evaluation with User Error and the value |
error("message") | Stops evaluation with the message |
read("env:NAME"), read("prop:NAME") | The value, or null. Other URIs return null; read does not load files. |
read_env("NAME") | The environment variable, or an error when it is unset |
Reads go through the evaluator's security manager. Contracts must not depend on environment values; declare a runtime secret.
String members
| Member | Result | Notes |
|---|---|---|
length | Int | Counts Unicode scalar values |
isEmpty, isNotEmpty | Boolean | |
trim, trimStart, trimEnd | String | Properties: write name.trim, not name.trim() |
reverse | String | Property |
chars | List of one-character strings | Property |
codePoints | List of Int | Property |
md5, sha256 | Lowercase hex digest | Property |
base64, base64Decoded | String | Property. Decoding invalid base64 or non-UTF-8 bytes fails. |
toUpperCase(), toLowerCase() | String | |
substring(start, end) | String | Byte offsets. An index inside a multi-byte character stops the 0.149.1 CLI with an internal error. |
repeat(count) | String | |
padStart(width, char), padEnd(width, char) | String | Uses the first character of char |
contains(s), startsWith(s), endsWith(s) | Boolean | |
split(separator) | List | |
replaceFirst(pattern, replacement), replaceAll(pattern, replacement) | String | |
matches(regex) | Boolean | Needs a Regex value |
encodeToBytes() | Bytes | Bytes cannot be rendered in output |
labels = ["one", "two"].map((value) -> value.toUpperCase())
csv = labels.join(",")
padded = "5".padStart(3, "0")
trimmed = " orders ".trim{
"csv": "ONE,TWO",
"labels": [
"ONE",
"TWO"
],
"padded": "005",
"trimmed": "orders"
}Number members
| Type | Members |
|---|---|
Int | isEven, isOdd, abs, sign |
Float | isFinite, isNaN, ceil, floor, round(), toInt() |
Wrap a negative literal in parentheses before a member: (-4).abs.
List members
| Member | Result |
|---|---|
length, isEmpty | Int, Boolean |
first, last | The element; fails on an empty list |
rest | Every element after the first |
reverse(), distinct() | List |
add(value) | A new list with the value appended |
map(f), filter(f), flatMap(f) | List. flatMap needs f to return a list. |
fold(initial, (acc, x) -> ...) | The accumulated value |
join(separator) | String |
minBy(f), maxBy(f) | The element with the smallest or largest key |
zip(other) | A list of two-element lists |
partition(f) | [matching, notMatching] |
Listing { ... } values and objects do not have these members.
Declared but not available in 0.149.1
These are declared in acore:base or other modules but are not bound in the
0.149.1 evaluator. Using them fails with Property ... not found,
Not a function or Undefined.
| Area | Not available |
|---|---|
| String | lastIndex, getOrNull, toInt, toFloat, toBoolean |
| Number | isPositive, isInfinite, isNonZero; Int.toFloat(), Int.toRadixString(); isFinite and isNaN on Int |
| Boolean | xor, implies |
| List | contains |
| Constructors | Regex(pattern), List(...), Set(...), Map(...) |
| Modules | acore:math functions and constants, json.parse, yaml.parse |
The evaluator implements members for Set, Map and Regex values (for
example Map.containsKey, Regex.matchEntire), but 0.149.1 gives source no
way to construct those values.
Contract schema classes
acore:base also declares the service contract API: Config, project and
backend configuration, policies, models, endpoints, types, domain and security
models, mocks and tests. They are catalogued in the
Acore schema reference. Backend
declarations have their own catalog: run axiom explain --schema.
Backend pure functions
Backend pure fn bodies and validators use a separate set of checked
intrinsics: string and list methods in the
checked expression grammar
and the canonical codec functions in
Validation.
Related
Streams and WebSockets
Declare HTTP streams, server-sent events, WebSockets and file streams on an endpoint, and bound how a frontend view keeps stream data.
Domain and security models
Add optional entities, relationships, invariants, projections and security policy to a backend contract, compiled into signed manifests.