Standard Library Overview
The Almide standard library covers data types, I/O, networking, numerics and
more. Modules are either auto-imported (usable with no import statement at
all) or require an explicit import.
The split is not stylistic: everything that can touch the outside world — files, the network, the clock as a source of entropy, the process environment — is import-required, so a file’s imports are an honest summary of what it can reach.
Auto-imported modules
Section titled “Auto-imported modules”Available in every file with no import statement. Writing import string is
redundant.
| Module | Description |
|---|---|
| string | String manipulation: trim, split, join, replace, search |
| list | List operations: map, filter, fold, sort, search |
| map | Map (dictionary) operations: get, set, merge, iterate |
| set | Set operations: union, intersection, difference |
| int | Integer conversion, parsing, bitwise operations |
| float | Float conversion, rounding, math utilities |
| math | Mathematical functions: trig, logarithms, constants |
| option | Option[T] utilities: map, flat_map, unwrap_or |
| result | Result[T, E] utilities: map, flat_map, unwrap_or |
| value | Generic dynamic value type shared with JSON |
| error | Error construction and chaining |
| datetime | Date/time: parse, format, arithmetic |
| bytes | Binary data: read/write, slice, encode, decode |
| matrix | Matrix operations: create, multiply, transpose |
| sized numeric types | int8…int32, uint8…uint64, float32 |
Import-required modules
Section titled “Import-required modules”These need import <module>:
I/O and system
Section titled “I/O and system”| Module | Description | Effect |
|---|---|---|
| fs | File system: read, write, list directories | Yes |
| io | Console I/O: read_line, print (no newline), read_all | Yes |
| env | Environment: args, env vars, timestamps, sleep | Yes |
| process | Process execution, env vars, spawn/kill, signals | Yes |
| path | Path manipulation: join, dirname, basename, extension | No |
| args | Command-line flag and option parsing | No |
Data formats
Section titled “Data formats”| Module | Description | Effect |
|---|---|---|
| json | JSON parsing, building, path-based access | No |
| regex | Regular expressions: match, find, replace, split | No |
| base64 | Base64 encoding and decoding | No |
| hex | Hexadecimal encoding and decoding | No |
Networking
Section titled “Networking”| Module | Description | Effect |
|---|---|---|
| http | HTTP client and server | Yes |
Development
Section titled “Development”| Module | Description | Effect |
|---|---|---|
| testing | Test assertions: assert_eq, assert_approx, assert_throws | No |
| random | Random number generation | Yes |
Module Categories
Section titled “Module Categories”Data Type Modules
Section titled “Data Type Modules”Each built-in data type has a corresponding module for operations:
string.len("hello") // => 5list.map([1, 2, 3], (x) => x * 2) // => [2, 4, 6]map.get(m, "key") // => Option[V]int.to_string(42) // => "42"float.round(3.7) // => 4.0Container Modules
Section titled “Container Modules”option.unwrap_or(some(42), 0) // => 42result.map(ok(1), (x) => x + 1) // => ok(2)set.union(a, b) // set unionI/O Modules
Section titled “I/O Modules”Most I/O is effect fn returning Result, but not all of it — fs.exists
and its siblings are effectful yet return Bool, and fs.temp_dir, env.os,
process.args and several io writers are pure. Check the per-module page
before assuming:
import fs
effect fn read_config() -> Result[String, String] = { let text = fs.read_text("config.toml")! ok(text)}Functional Operations
Section titled “Functional Operations”Many modules share a consistent vocabulary for higher-order operations:
| Function | Available on |
|---|---|
map | list, map, set, option, result |
filter | list, map, set, option |
fold | list, map, set |
each | list, map, set |
any / all | list, map, set |
find | list, map |
contains | list, map, set |
len | list, map, set, string |
is_empty | list, map, set, string |
UFCS (Universal Function Call Syntax)
Section titled “UFCS (Universal Function Call Syntax)”All stdlib functions can be called in either prefix or method style:
// These are equivalent:string.len("hello")"hello".len()
// Chaining with method syntax:text.trim().split(",").map((s: String) => s.to_upper())
// Chaining with pipe:text |> string.trim |> string.split(",")Naming Conventions
Section titled “Naming Conventions”- One name per operation:
lennotlength/size/count is_prefix: Boolean-returning functions (is_empty,is_digit)to_prefix: Type conversion (to_string,to_int)from_prefix: Construction from another type (from_list,from_bytes)- One canonical name: the name listed here is the one to use (a few aliases exist for historical reasons, e.g.
string.length)