Native Modules
Native modules expose runtime functionality through stable tyrus:* import paths. Their APIs are concise, and their implementations are linked into native binaries. Every module is part of the standard distribution, no package manager, no npm install, no external runtime.
Available Modules
| Module | Purpose |
|---|---|
tyrus:algorithm | Native data structures and algorithms for sorting, searching, graphs, trees, and collections. |
tyrus:archive | Create, inspect, and safely extract ZIP, TAR, and TAR.GZ archives. |
tyrus:cli | Interactive terminal prompt helpers. |
tyrus:compress | Compress and decompress bytes with Gzip, Deflate, raw Deflate, and Brotli. |
tyrus:crypto | Cryptographic primitives: digest, HMAC, AES-256-GCM, Argon2, JWT, and secure random. |
tyrus:db | Versioned SQLite schema snapshots, read-only schema checks, and the database error contract. |
tyrus:encoding | Explicit UTF-8, UTF-16, hexadecimal, Base64, Base32, and radix conversion. |
tyrus:fs | Synchronous file reads and writes for native programs. |
tyrus:http | HTTP server, route, response, status, and API-oriented helpers. |
tyrus:math | Mathematical constants and functions. |
tyrus:memory | Explicit ownership, secure erasure, and compile-time layout queries. |
tyrus:net | Address parsing, Result-based name resolution, asynchronous TCP and UDP networking, and capability-gated probes. |
tyrus:os | Cross-platform operating system identification: platform, architecture, hostname, locale. |
tyrus:process | Shell-free subprocesses with bounded standard byte streams. |
tyrus:simd | Vectorized addition of equal-length f32[] and f64[] arrays with recoverable Result errors. |
tyrus:stream | Bounded progressive transport with capability-separated reading and writing. |
tyrus:task | Cooperative async task management: cancellation and timed suspension. |
tyrus:temporal | Native instants, calendar values, durations, and IANA time zones. |
tyrus:test | Test suites, assertions, hooks, and modifiers run by tyrus test. |
tyrus:utils | Native text helpers such as ANSI styling and FIGlet banners. |
Import Style
tyrus
import { readFileSync } from "tyrus:fs";
import { HttpStatus } from "tyrus:http";
import { input } from "tyrus:cli";
import { styleText } from "tyrus:utils";
import { digest, hmac, cipher, jwt } from "tyrus:crypto";
import { cancel, sleep } from "tyrus:task";tyrus:* imports are resolved by the compiler as built-in modules.
Using Modules Together
Native modules compose naturally. A typical CLI project might read config from the filesystem, prompt for input, and apply styles:
tyrus
import { writeFileSync, type FsError } from "tyrus:fs";
import { input, confirm } from "tyrus:cli";
import { styleText } from "tyrus:utils";
const main = (): void => {
const name: string = input({ message: "Project name?" });
const proceed: boolean = confirm({ message: `Create "${name}"?` });
if (proceed) {
match (writeFileSync(`${name}/main.tyr`, `print("hello from ${name}");`)) {
Ok() => print(styleText("green", `Created ${name}`));
Err(error) => printError(error.message);
}
}
};Runtime Boundary
Native modules should document their public imports, return types, error behavior, and diagnostics before being considered stable. APIs that print terminal UI chrome use stderr so stdout remains reserved for normal program output.
