Alpha.16 · standard library

Standard library

Find module references and guides, and choose ordinary or async imports.

These pages describe alpha.16. Host I/O requires the native toolchain; browser capabilities are limited. Browse the stdlib guides.

Find the alpha.16 standard-library module for your task, then open its reference for signatures, parameters, results, errors and limits. Install the matching compiler, VM and library together. Host I/O examples require the native toolchain.

Choose an import, keep the function names

import stdlib/time as time

An ordinary function calls time.now() directly. An async function instead uses:

import stdlib/time/async as time

and calls await time.now(). Both return Result[Instant,ClockError]. Pure helpers such as time.seconds(5) remain ordinary pure calls, even through the async import. An async import does not make every exported function async.

The module path selects the effect. Async functions may call pure code and await async operations; importing an ordinary blocking function does not make calling that function safe inside an async handler. A clock read is impure because its result depends on when the call occurs.

Module map

Paths below follow stdlib/. An /async counterpart exports the same value and error identities where both interfaces exist. Each module page includes signatures, parameters, return values, behaviour and errors. Ordinary and async forms are documented together.

NeedOrdinary moduleAsync moduleMain operations
Monotonic clock and timerstimetime/asyncnow, sleep; pure duration factories
Shared cellsstatestate/asynccreate, read, update
Environmentenvironmentenvironment/asyncget
Checked console I/Oconsoleconsole/asyncread, write, write_line, write_error, write_error_line
Subprocessesprocessprocess/asyncrun(Command), arguments, exit
Files and directoriesfilesystemfilesystem/asyncmetadata, bounded reads, writes, directory operations
Confined filesystem accessfilesystem/confinedfilesystem/confined/asyncread, read_link, root_identity
Staged directory publicationfilesystem/stagingfilesystem/staging/asynccreate, path, create_directory, write_chunk, create_symlink, publish, discard
SHA-256digest/sha256digest/sha256/asynccreate, update, finish, close; pure hash
Gzip decodingcompression/gzipcompression/gzip/asynccreate_decoder, decode_chunk, close
Raw HTTP transportnetwork/http_streamnetwork/http_stream/asyncopen, read, close
TCP clients and servicesNo canonical blocking counterpartnetwork/tcp/asyncexchange, serve_bounded, serve_stream, serve, read_chunk
Nested bytecode executionruntime/bytecodeNo async counterpartOrdinary runtime support; not a handler API

Pure operations need no async twin: path construction, byte slicing, checked UTF-8 decoding, numeric operations and persistent collections can be called from either kind of function.

The testing modules provide assertions; testing/filesystem, testing/process and testing/reporting have /async counterparts for effectful test support.

Streams and owned resources

Use the module reference for each resource's ownership, limits, cancellation and cleanup contract. The async resource guide shows complete SHA-256 and gzip workflows. The input and publication guide combines console input, staging and confined reads.

For complete HTTP requests, start with the HTTP Client reference. For incoming requests, use the HTTP Server reference and Server Playbook.

Handle domain errors

Read the error contract on the relevant module page. Where an error exposes a category, use it for control flow and its documented rendering method for a human explanation. Do not parse diagnostic prose or automatically retry every error. There is no universal error record or rendering method.

For example, filesystem errors, process errors and HTTP stream errors have different context and native-detail types. Pure value failures are documented with paths, durations and UTF-8 decoding.

See the migration guide when replacing compatibility imports.

Testing reference

Anonymous functions, closures and State

The callable and State guide combines these features in a standalone counter and equivalent async HTTP handlers.

Keep exploring

Explore Panackelty.