Hew reference
Guides
Start here
- BasicsWrite a first program and work with values, collections, and basic types.
- Core conceptsUnderstand ownership, messages, actors, and task lifecycles.
- Control flowChoose with if and match, loop, and return values from blocks.
Build programs
- Functions and errorsDefine reusable behavior with generics and explicit failure handling.
- Types and traitsModel data and shared behavior with records, enums, traits, and patterns.
- Ownership and sendingKnow when data copies, moves, or transfers to concurrent work.
- Modules and packagesOrganize code, import dependencies, and cross native boundaries.
Concurrent systems
- ActorsIsolate state and coordinate work through typed messages.
- Structured concurrencyStart tasks, await results, and keep their lifetimes bounded.
- Resources and cleanupManage files, sockets, and other single-owner values safely.
- SupervisionRestart failed actors under explicit strategies and budgets.
- State machinesExpress events, states, and exhaustive transitions.
Specialized tools
- Compile-time codeUse macros, compile-time inputs, and generated sources.
- Tests and benchmarksFind, filter, and run tests, examples, and benchmarks.
- Wire dataDesign stable schemas for services and remote actors.
- Target capabilitiesChoose host, browser, sandbox, or WASI execution.
Standard library
Import a module by its dotted name. Each page lists its public declarations and methods.
std.arenaGenerational-index slotmap (Arena<T>).std.benchBenchmarks run with hew bench on the host clock.std.builtinsBuilt-in types, traits, and functions available in every Hew program.std.cacheKeyed memoization with optional expiry and bounded FIFO eviction.std.cliCommand-line parsing over supplied argument strings.std.dequeDouble-ended queue (deque).std.failureCrash details and recovery decisions for actor lifecycle hooks.std.fmtInteger formatting utilities.std.fsFile system operations.std.ioStandard I/O operations.std.iterIterator combinators for Vec<T> and any Iterator implementation.std.lazyA single-owner value initialized on first demand.std.link_monitorActor monitor and link handle helpers.std.logStructured logging with level filters and text or JSON output.std.mathMathematical operations.std.metricsDeveloper-defined application metrics.std.netTCP networking.std.observeRuntime observability reads.std.optionInspect, transform, or extract a value that may be absent.std.osOperating system interfaces.std.pathFile path and glob utilities.std.pipelineBounded concurrent adapters for owned iterators.std.processProcess execution.std.randomSeedable pseudo-random number generation.std.restartRestart delay policies for supervisor declarations.std.resultInspect, transform, or add context to an explicit success or error value.std.semaphoreCounting semaphore for concurrency control.std.sortStable sorting and reversal for vectors.std.streamTyped streams and sinks for in-memory pipes, files, sockets, and actors.std.stringstring conversion and manipulation utilities.std.testingControls for deterministic Hew tests and runs.std.uuidUUID generation and validation.std.vecGeneric vector utilities. Empty vectors return None for lookups and extrema.
concurrency
std.concurrency.lifecycleGeneric lifecycle state machine for resource-owning services.
crypto
std.crypto.encryptSymmetric encryption and decryption.std.crypto.hashCryptographic hashing and utilities.std.crypto.jwtJSON Web Token encoding and validation.std.crypto.passwordPassword hashing and verification (Argon2id).std.crypto.signEd25519 signing keys and signature verification (RFC 8032).
encoding
std.encoding.base64Base64 encoding and decoding — pure Hew implementation.std.encoding.binaryFixed-width integer and IEEE 754 binary32 encoding in little-endian and big-endian byte order.std.encoding.cborCBOR (RFC 8949) encoding of any data value.std.encoding.compressCompression and decompression (gzip, deflate, zlib).std.encoding.csvCSV parsing — pure Hew implementation.std.encoding.hexHexadecimal encoding and decoding.std.encoding.jsonJSON values with automatic cleanup and independent copies.std.encoding.markdownMarkdown to HTML conversion.std.encoding.msgpackMessagePack serialization.std.encoding.protobufProtocol Buffers message construction.std.encoding.tomlTOML values with automatic cleanup and independent copies.std.encoding.utf8Validating and lossy UTF-8 decoding with explicit byte-position errors.std.encoding.wireShared types of the data codecs, and the #[wire] schema layer.std.encoding.xmlXML parsing and manipulation.std.encoding.yamlYAML values with automatic cleanup and independent copies.
io
std.io.scannerLine-by-line and word-by-word scanner (bufio.Scanner-style).
machine
std.machine.historyRetain selected compound subtrees alongside an ordinary machine value.std.machine.watchBounded, lag-visible observation of an explicitly owned machine.
net
std.net.clusterInspect this node's current cluster membership and registered names.std.net.configNode configuration from [cluster] in hew.toml and HEW_NODE_* overrides.std.net.dnsDNS hostname resolution.std.net.http.clientHTTP client module for outbound requests.std.net.http.codecBuild HTTP/1.1 requests and parse buffered responses over std.net.std.net.http.codec.requestParse buffered HTTP/1.1 requests and build server responses over std.net.std.net.http.routerMethod and path routing over ordinary Hew values.std.net.http.serverHTTP server for handling web requests.std.net.ipnetIP address and CIDR utilities.std.net.mimeMIME type detection.std.net.quicQUIC transport for internode messaging.std.net.smtpSMTP client for sending email.std.net.tlsTLS client connections.std.net.urlURL parsing.std.net.websocketWebSocket client and server for bidirectional communication.
text
std.text.regexRegular expression matching.std.text.semverSemantic versioning — pure Hew implementation.std.text.templateGo-style text/template rendering.
time
std.time.cronCron expressions over precise wall-clock timestamps.std.time.datetimeUTC calendar views of precise wall-clock timestamps.