The core floor fixes construction, conversion, text scalar access, higher-order collection transforms, Option/Result helpers, and profile-gated testing without hidden coercion.
Canonical contract
Prelude constructors are Some, None, Ok, and Err; unsolved type variables require an expected type. print accepts a string only. toInt and related conversions use Option or declared failure values rather than exceptions. s.scalars() returns single-scalar strings; string .length remains absent. Free map, filter, and reduce consume only the fixed iterable families.
Public surface
The checked inventory extends the minimum with toIntRadix, fromCodePoint, toFloat, input, Math’s 13 members, string search/trim/split/slice/replace members, Option okOr/okOrElse/map/flatMap, Result map/flatMap, immutable Bytes, fixed-length mutable ByteBuffer, Encoding conversions, hashes, structured format helpers, Date, BigInt, Decimal, and exact JSON decode heads.
Observable behavior
String operations use scalar or explicitly named byte semantics. Higher-order calls evaluate inputs and callbacks in defined collection order. Option.map and optional access preserve/flatten the Option model as specified; Result mapping does not turn faults into Err. Typed JSON requires one written fully known target and returns deterministic $-rooted decode paths on data failure.
Binary assembly
Use ByteBuffer.allocate(length, value = 0) when an algorithm must write many bytes into one contiguous fixed-length value. set, fill, and copy require a let mut receiver root. All indexes, ranges, and byte values (0..255) are checked before a write; an invalid operation raises a fault without partially changing the buffer. Assignment shares the mutable identity, while ByteBuffer.fromBytes copies in and toBytes() creates an immutable snapshot.
let mut row = ByteBuffer.allocate(8)
row.fill(0, 8, 255)
row.set(0, 137)
let mut frame = ByteBuffer.allocate(12)
frame.copy(row, 0, 2, 8)
let payload = frame.toBytes()ByteBuffer itself cannot cross a Web export, participate in equality or ordering, serve as a Map/Set key, be interpolated into text/templates, or be encoded as JSON. Snapshot it to Bytes and encode explicitly at a text or ABI boundary. Release qualification includes a reference optimized-Web throughput check, but its machine-specific threshold is not a portable timing guarantee for every browser or device.
CRC-32 integrity checksum
Hash.crc32(data) returns the unsigned CRC-32/ISO-HDLC value in 0..4294967295. It is useful for file-format and transport integrity fields, but it is not a cryptographic digest and must not be used for authentication or adversarial tamper resistance.
let checksum = Hash.crc32(Bytes.encodeUtf8("123456789"))
print("{checksum}")This example prints 3421780262. Direct execution, generated Rust, generated Python, raw Web, Web Worker, and the Playground produce the same unsigned integer. std.hash.crc32 exposes the same operation.
Deterministic fixed DEFLATE
Use Codec.deflateFixedCompress(bytes) when a file format needs one canonical raw fixed-Huffman DEFLATE block. The result has no zlib or gzip header, checksum, or trailer. Search and memory are bounded, and input above 256 MiB returns Err.
match Codec.deflateFixedCompress(Bytes.encodeUtf8("hello")) {
case Ok(compressed) => print(compressed.toHex())
case Err(error) => print("error: {error}")
}Direct execution, generated Rust, raw Web, Web Worker, and the Playground produce identical bytes. Generated Python rejects this function before writing an artifact.
Deterministic fixed zlib
Use Codec.zlibFixedCompress(bytes) when a file format needs a complete deterministic zlib stream rather than raw DEFLATE. It writes the fixed 78 01 header, the exact fixed-Huffman stream described above, and the original input's Adler-32 trailer. Input above 256 MiB returns Err.
match Codec.zlibFixedCompress(Bytes.encodeUtf8("hello")) {
case Ok(compressed) => print(compressed.toHex())
case Err(error) => print("error: {error}")
}This prints 7801cb48cdc9c90700062c0215. Direct execution, generated Rust, raw Web, Web Worker, and the Playground produce identical bytes. Generated Python rejects this function before writing an artifact. This operation does not add general Adler-32, decompression, compression levels, dictionaries, or streaming.
Reed–Solomon protection
Use Codec.reedSolomon255223Protect(bytes) to produce systematic RS(255,223) codewords. Every 223-byte data shard is followed by 32 parity bytes; the final data shard is zero-padded. The caller keeps the original logical length because the protected bytes do not add a length prefix.
match Codec.reedSolomon255223Protect(Bytes.encodeUtf8("hello")) {
case Ok(protected) => print("{protected.length()} bytes")
case Err(error) => print("error: {error}")
}The input must be non-empty and may use at most 65,535 shards. This function generates protection bytes; it does not detect or correct errors. Direct execution, generated Rust, raw Web, Web Worker, and the Playground agree exactly. Generated Python rejects this function before writing an artifact.
Current support
Core names are checked statically, and the virtual std root exposes a fixed module surface. Host functions such as print and input are available only in environments that provide the required input and output capabilities.
Constraints and exclusions
Do not print non-strings without interpolation, infer an unconstrained None/empty collection, treat strings as arrays, assume user-defined Iterable, catch faults with Result helpers, decode recursive/open/imported nominal schemas, or expose test helpers on the public profile. assert is a function only in test-profile, never a language keyword.
Worked example
function parseAll(values: Array<string>) -> Array<Option<int>> {
return map(values, value => toInt(value))
}
let scalars = "토파즈".scalars()
let parsed = parseAll(["1", "x", "3"])
print("{scalars.length}:{parsed}")