std
v0.0.43Standard library for Riot
riot add std std = "0.0.43" - Last release
- May 15, 2026
- License
- Apache-2.0
- Dependencies
- 1
- Dependents
- 57
- Installs
- 156
- Published versions
- 33
- Owner
-
@leostera
README Expand Collapse
std
Riot's standard library for building real applications.
std is the package most Riot users should start with. It is not just a bag of
helpers. It is the application-facing layer that brings together Riot's actor
runtime, supervision model, filesystem and process I/O, networking, data
formats, testing, benchmarking, configuration, logging, and the everyday
utility modules you end up reaching for in real programs.
If you are building an application, a service, a CLI, a tool, or a test suite in Riot, this is usually the right package to depend on first.
Install
riot add std
When to reach for std
Use std when you want one cohesive surface for:
- actor-oriented concurrency and supervision;
- files, directories, paths, and generic I/O;
- JSON, TOML, CSV, XML, S-expressions, and text encoding;
- TCP, TLS, HTTP data types, URIs, and addresses;
- structured logging, telemetry, configuration, and environment handling;
- testing, benchmarking, worker pools, and background jobs;
- Unicode-aware strings, iterators, collections, graphs, and utilities.
Use a lower-level package like kernel only when you specifically need its
lower-level primitives or you are implementing infrastructure that sits under
std.
Quick start
open Std
let load_config = fun path ->
Fs.read (Path.v path)
|> Result.and_then Data.Toml.parse_string
let main = fun ~args:_ ->
let config =
load_config "riot.toml"
|> Result.expect ~msg:"failed to load config"
in
ignore config;
Log.info "loaded config successfully";
Ok ()
let () = Runtime.run ~main ~args:Env.args ()
What std includes
std is broad. The easiest way to approach it is by domain.
Application and process model
Applicationfor ordered startup and shutdown of multi-part systems.Agentfor simple shared state built on actors.Supervisorfor fault-tolerant process trees.Process,Pid,Message,Task,Timer, andWorkerPoolfor everyday process lifecycle, async work, time-based work, and parallel execution.GlobalandSystemfor runtime-wide state and system queries.
Filesystem, paths, and I/O
Fsfor high-level filesystem work.Fs.File,Fs.Fd,Fs.Metadata,Fs.Permissions, andFs.ReadDirfor more focused file and directory control.Fs.FileWatcherandFs.Walkerfor watching and traversing directory trees.IOfor generic readers, writers, and streaming-style APIs.Pathfor typed, composable filesystem paths.ArchiveandCompressfor tar and gzip operations.
Networking and protocols
Netas the umbrella networking namespace.Net.Addr,Net.Uri,Net.TcpClient,Net.TcpListener,Net.TcpServer,Net.TcpStream, andNet.TlsStream.Net.Httpand its submodules:Header,Method,Request,Response,Status, andVersion.
Data formats and encoding
Data.Json,Data.Toml,Data.Csv,Data.Xml, andData.Sexp.Encoding.Base16,Encoding.Base32,Encoding.Base64,Encoding.Base85, andEncoding.Octal.RegexandGlobfor matching and pattern compilation.
Logging, configuration, and observability
Logand its related modules for structured logging.Telemetryfor emitting measurements and events.Config,Config.Loader,Config.Provider,Config.Server,Config.Spec, andConfig.Validator.EnvandCommandfor environment access and external process execution.
Collections and iteration
Collectionsand its core structures, includingDequeandHeap.Iterand iterator/cursor tooling for functional and parsing-oriented iteration.Graph,Graph.SimpleGraph,Graph.Dot, andGraph.Mermaid.
Time, dates, randomness, and identifiers
Time,Time.Duration,Time.Instant, andTime.SystemTime.DatetimeandCalendar.Random,UUID, andVersion.
Text, Unicode, and language-facing utilities
String,Char,Uchar, andUnicode.- Unicode-aware helpers for graphemes, segmentation, width, and UTF-8/UTF-16.
Diff,ArgParser,Sync,Type,Ref,Ptr, andException.
Cryptography and hashing
Crypto,Crypto.Digest, andCrypto.Hasher.- Concrete algorithms including
Md5,Sha1,Sha256, andSha512.
Testing and benchmarking
Testand its supporting modules:Assertions,Cli,FixtureRunner,Reporter,Snapshot,TestContext, and more.Benchand its runner/reporting surface for repeatable benchmarks.
Module map
If you like scanning names before digging deeper, this is the condensed map of the package surface:
- Runtime and application:
Application,Agent,Supervisor,Process,Pid,Message,Task,Timer,WorkerPool,Global,System - Filesystem and I/O:
Fs,Fs.File,Fs.Fd,Fs.Metadata,Fs.Permissions,Fs.ReadDir,Fs.FileWatcher,Fs.Walker,IO,Path,Archive,Compress - Networking:
Net,Net.Addr,Net.Uri,Net.TcpClient,Net.TcpListener,Net.TcpServer,Net.TcpStream,Net.TlsStream,Net.Http - Data and codecs:
Data.Json,Data.Toml,Data.Csv,Data.Xml,Data.Sexp,Encoding,Regex,Glob - Ops and runtime support:
Config,Log,Telemetry,Env,Command - Core utilities:
Result,Option,String,Bool,Char,Int,Int32,Int64,Float,UUID,Version,Random,Ref,Ptr,Type - Iteration and structure:
Collections,Iter,Graph,Diff,Sync - Time:
Time,Datetime,Calendar - Unicode:
Unicode,Uchar - Crypto:
Crypto - Validation and tooling:
Test,Bench,ArgParser,GenStage
Examples
std already ships with runnable examples. Two good entry points are:
riot run -p std hello_world
riot run -p std walker_find -- --count-only packages/std/examples
The examples directory currently includes:
hello_world.mlfor the smallest possibleStd+Runtime.runprogram.walker_find.mlfor recursive filesystem walking and glob-based filtering.test_uri.mlfor URI parsing and manipulation.unicode_example.ml,test_unicode_tables.ml, andword_navigation_example.mlfor Unicode and text segmentation work.uuid_test.mlfor UUID generation and formatting.bench_demo.ml,vector_bench.ml, andhashmap_bench.mlfor the benchmark surface.debug_query.mlandline_wrapping_example.mlfor focused text and tooling helpers.
Where to read next
src/std.mliis the authoritative top-level module guide.examples/is the fastest way to see package pieces working together.tests/is useful when you want executable examples of specific edge cases and expected behavior.
Related packages
kernelis the lower-level substrate beneathstd.actorsis a compatibility facade overStd.Runtimewhile the repo finishes migrating off the old package boundary.blinkbuilds an HTTP client on top of the same model.suriis the web framework layer when you need HTTP routing and server-side application structure.
std
Riot's standard library for building real applications.
std is the package most Riot users should start with. It is not just a bag of
helpers. It is the application-facing layer that brings together Riot's actor
runtime, supervision model, filesystem and process I/O, networking, data
formats, testing, benchmarking, configuration, logging, and the everyday
utility modules you end up reaching for in real programs.
If you are building an application, a service, a CLI, a tool, or a test suite in Riot, this is usually the right package to depend on first.
Install
riot add std
When to reach for std
Use std when you want one cohesive surface for:
- actor-oriented concurrency and supervision;
- files, directories, paths, and generic I/O;
- JSON, TOML, CSV, XML, S-expressions, and text encoding;
- TCP, TLS, HTTP data types, URIs, and addresses;
- structured logging, telemetry, configuration, and environment handling;
- testing, benchmarking, worker pools, and background jobs;
- Unicode-aware strings, iterators, collections, graphs, and utilities.
Use a lower-level package like kernel only when you specifically need its
lower-level primitives or you are implementing infrastructure that sits under
std.
Quick start
open Std
let load_config = fun path ->
Fs.read (Path.v path)
|> Result.and_then Data.Toml.parse_string
let main = fun ~args:_ ->
let config =
load_config "riot.toml"
|> Result.expect ~msg:"failed to load config"
in
ignore config;
Log.info "loaded config successfully";
Ok ()
let () = Runtime.run ~main ~args:Env.args ()
What std includes
std is broad. The easiest way to approach it is by domain.
Application and process model
Applicationfor ordered startup and shutdown of multi-part systems.Agentfor simple shared state built on actors.Supervisorfor fault-tolerant process trees.Process,Pid,Message,Task,Timer, andWorkerPoolfor everyday process lifecycle, async work, time-based work, and parallel execution.GlobalandSystemfor runtime-wide state and system queries.
Filesystem, paths, and I/O
Fsfor high-level filesystem work.Fs.File,Fs.Fd,Fs.Metadata,Fs.Permissions, andFs.ReadDirfor more focused file and directory control.Fs.FileWatcherandFs.Walkerfor watching and traversing directory trees.IOfor generic readers, writers, and streaming-style APIs.Pathfor typed, composable filesystem paths.ArchiveandCompressfor tar and gzip operations.
Networking and protocols
Netas the umbrella networking namespace.Net.Addr,Net.Uri,Net.TcpClient,Net.TcpListener,Net.TcpServer,Net.TcpStream, andNet.TlsStream.Net.Httpand its submodules:Header,Method,Request,Response,Status, andVersion.
Data formats and encoding
Data.Json,Data.Toml,Data.Csv,Data.Xml, andData.Sexp.Encoding.Base16,Encoding.Base32,Encoding.Base64,Encoding.Base85, andEncoding.Octal.RegexandGlobfor matching and pattern compilation.
Logging, configuration, and observability
Logand its related modules for structured logging.Telemetryfor emitting measurements and events.Config,Config.Loader,Config.Provider,Config.Server,Config.Spec, andConfig.Validator.EnvandCommandfor environment access and external process execution.
Collections and iteration
Collectionsand its core structures, includingDequeandHeap.Iterand iterator/cursor tooling for functional and parsing-oriented iteration.Graph,Graph.SimpleGraph,Graph.Dot, andGraph.Mermaid.
Time, dates, randomness, and identifiers
Time,Time.Duration,Time.Instant, andTime.SystemTime.DatetimeandCalendar.Random,UUID, andVersion.
Text, Unicode, and language-facing utilities
String,Char,Uchar, andUnicode.- Unicode-aware helpers for graphemes, segmentation, width, and UTF-8/UTF-16.
Diff,ArgParser,Sync,Type,Ref,Ptr, andException.
Cryptography and hashing
Crypto,Crypto.Digest, andCrypto.Hasher.- Concrete algorithms including
Md5,Sha1,Sha256, andSha512.
Testing and benchmarking
Testand its supporting modules:Assertions,Cli,FixtureRunner,Reporter,Snapshot,TestContext, and more.Benchand its runner/reporting surface for repeatable benchmarks.
Module map
If you like scanning names before digging deeper, this is the condensed map of the package surface:
- Runtime and application:
Application,Agent,Supervisor,Process,Pid,Message,Task,Timer,WorkerPool,Global,System - Filesystem and I/O:
Fs,Fs.File,Fs.Fd,Fs.Metadata,Fs.Permissions,Fs.ReadDir,Fs.FileWatcher,Fs.Walker,IO,Path,Archive,Compress - Networking:
Net,Net.Addr,Net.Uri,Net.TcpClient,Net.TcpListener,Net.TcpServer,Net.TcpStream,Net.TlsStream,Net.Http - Data and codecs:
Data.Json,Data.Toml,Data.Csv,Data.Xml,Data.Sexp,Encoding,Regex,Glob - Ops and runtime support:
Config,Log,Telemetry,Env,Command - Core utilities:
Result,Option,String,Bool,Char,Int,Int32,Int64,Float,UUID,Version,Random,Ref,Ptr,Type - Iteration and structure:
Collections,Iter,Graph,Diff,Sync - Time:
Time,Datetime,Calendar - Unicode:
Unicode,Uchar - Crypto:
Crypto - Validation and tooling:
Test,Bench,ArgParser,GenStage
Examples
std already ships with runnable examples. Two good entry points are:
riot run -p std hello_world
riot run -p std walker_find -- --count-only packages/std/examples
The examples directory currently includes:
hello_world.mlfor the smallest possibleStd+Runtime.runprogram.walker_find.mlfor recursive filesystem walking and glob-based filtering.test_uri.mlfor URI parsing and manipulation.unicode_example.ml,test_unicode_tables.ml, andword_navigation_example.mlfor Unicode and text segmentation work.uuid_test.mlfor UUID generation and formatting.bench_demo.ml,vector_bench.ml, andhashmap_bench.mlfor the benchmark surface.debug_query.mlandline_wrapping_example.mlfor focused text and tooling helpers.
Where to read next
src/std.mliis the authoritative top-level module guide.examples/is the fastest way to see package pieces working together.tests/is useful when you want executable examples of specific edge cases and expected behavior.
Related packages
kernelis the lower-level substrate beneathstd.actorsis a compatibility facade overStd.Runtimewhile the repo finishes migrating off the old package boundary.blinkbuilds an HTTP client on top of the same model.suriis the web framework layer when you need HTTP routing and server-side application structure.