Standard Library Overview
The Almide standard library provides 22 modules covering data types, I/O, networking, and more. Modules are either auto-imported (available without an import statement) or require explicit import.
Auto-Imported Modules
Section titled “Auto-Imported Modules”These modules are available in every Almide file without an import statement:
| 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 |
| int | Integer conversion, parsing, bitwise operations |
| float | Float conversion, rounding, math utilities |
| option | Option[T] utilities: map, flat_map, unwrap_or |
| result | Result[T, E] utilities: map, flat_map, unwrap_or |
| math | Mathematical functions: trig, logarithms, constants |
| set | Set operations: union, intersection, difference |
| value | Generic value type for JSON and dynamic data |
Import-Required Modules
Section titled “Import-Required Modules”These modules must be explicitly imported with 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: exec, exit, stdin | Yes |
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 |
| datetime | Date/time: parse, format, arithmetic | Mixed |
| bytes | Binary data: encode, decode, slice, hex | No |
| random | Random number generation | Yes |
Networking
Section titled “Networking”| Module | Description | Effect |
|---|---|---|
| http | HTTP client and server | Yes |
Numeric / Scientific
Section titled “Numeric / Scientific”| Module | Description | Effect |
|---|---|---|
| matrix | Matrix operations: create, multiply, transpose | No |
Development
Section titled “Development”| Module | Description | Effect |
|---|---|---|
| log | Structured logging | Yes |
| testing | Test utilities | No |
| error | Error type utilities | No |
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”All I/O functions are effect fn and return Result:
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) => 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)- No synonyms: The name listed in the docs is the only valid name