Acore language

[ 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.

Acore excerpt
import "acore:xml"
renderer = Renderer { indent = "    " }
URIContentsUsable in 0.149.1
acore:baseCore value classes, collections, Regex, Duration, DataSize, and the Axiom contract schema classesLoaded automatically into every module, so its classes need no import.
acore:mathDeclares min, max, sqrt, log, e and piNo. The declarations have no native binding, so the names are undefined after import.
acore:jsonDeclares parse(source: String): AnyNo native binding
acore:yamlDeclares parse(source: String): AnyNo native binding
acore:xmlRenderer { indent = " ", rootElementName = "root" }Yes, as a configuration class
acore:protobufRenderer { indent = " " }Yes, as a configuration class
acore:ProjectPackage { 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

FunctionResult
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

MemberResultNotes
lengthIntCounts Unicode scalar values
isEmpty, isNotEmptyBoolean
trim, trimStart, trimEndStringProperties: write name.trim, not name.trim()
reverseStringProperty
charsList of one-character stringsProperty
codePointsList of IntProperty
md5, sha256Lowercase hex digestProperty
base64, base64DecodedStringProperty. Decoding invalid base64 or non-UTF-8 bytes fails.
toUpperCase(), toLowerCase()String
substring(start, end)StringByte 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)StringUses the first character of char
contains(s), startsWith(s), endsWith(s)Boolean
split(separator)List
replaceFirst(pattern, replacement), replaceAll(pattern, replacement)String
matches(regex)BooleanNeeds a Regex value
encodeToBytes()BytesBytes cannot be rendered in output
strings.acore
labels = ["one", "two"].map((value) -> value.toUpperCase())
csv = labels.join(",")
padded = "5".padStart(3, "0")
trimmed = "  orders  ".trim
Output of axiom eval strings.acore -f json
{
  "csv": "ONE,TWO",
  "labels": [
    "ONE",
    "TWO"
  ],
  "padded": "005",
  "trimmed": "orders"
}

Number members

TypeMembers
IntisEven, isOdd, abs, sign
FloatisFinite, isNaN, ceil, floor, round(), toInt()

Wrap a negative literal in parentheses before a member: (-4).abs.

List members

MemberResult
length, isEmptyInt, Boolean
first, lastThe element; fails on an empty list
restEvery 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.

AreaNot available
StringlastIndex, getOrNull, toInt, toFloat, toBoolean
NumberisPositive, isInfinite, isNonZero; Int.toFloat(), Int.toRadixString(); isFinite and isNaN on Int
Booleanxor, implies
Listcontains
ConstructorsRegex(pattern), List(...), Set(...), Map(...)
Modulesacore: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.