Ovie ships with 11 standard library modules. Import them with use std::module_name.
std::core โ Core Types
The foundation: Result, Option, Vec, HashMap.
use std::core::{Result, Option, Vec, HashMap}
// Result โ success or failure
fn divide(a: Number, b: Number) -> Result {
if b == 0 { return Result.Err("Division by zero") }
return Result.Ok(a / b)
}
mut r = divide(10, 2)
if r.is_ok() { seeAm r.unwrap() } // 5
// Option โ value or nothing
fn find_user(id: Number) -> Option {
if id == 1 { return Option.Some("Alice") }
return Option.None()
}
mut u = find_user(1)
if u.is_some() { seeAm u.unwrap() } // Alice
// Vec โ dynamic array
mut v = Vec.new()
v = Vec.push(v, 10)
v = Vec.push(v, 20)
seeAm Vec.length(v) // 2
// HashMap โ key-value store
mut map = HashMap.new()
map = HashMap.insert(map, "name", "Ovie")
seeAm HashMap.get(map, "name") // Ovie
std::math โ Mathematics
Mathematical functions: sqrt, pow, abs, floor, ceil, min, max, round.
use std::math::{sqrt, pow, abs, floor, ceil, min, max}
seeAm sqrt(16.0) // 4.0
seeAm pow(2.0, 10.0) // 1024.0
seeAm abs(-42) // 42
seeAm floor(3.7) // 3.0
seeAm ceil(3.2) // 4.0
seeAm min(5, 3) // 3
seeAm max(5, 3) // 5
std::io โ Input/Output
Console I/O: println, print, read_line.
use std::io::{println, print, read_line}
print("Enter your name: ")
mut name = read_line()
println("Hello, " + name + "!")
std::fs โ File System
File operations: read_file, write_file, file_exists, make_dir, list_files.
use std::fs::{read_file, write_file, file_exists, make_dir}
if file_exists("data.txt") {
mut content = read_file("data.txt")
seeAm content
} else {
write_file("data.txt", "Hello from Ovie!")
}
make_dir("output")
write_file("output/result.txt", "Done!")
std::time โ Time Utilities
Time functions: now, duration_ms, sleep_ms.
use std::time::{now, duration_ms}
mut start = now()
// ... do work ...
mut elapsed = duration_ms(start, now())
seeAm "Elapsed: " + elapsed + "ms"
std::env โ Environment
Environment access: get_var, args, hostname.
use std::env::{get_var, args, hostname}
mut home = get_var("HOME")
mut host = hostname()
mut program_args = args()
seeAm "Running on: " + host
seeAm "HOME: " + home
std::cli โ Command Line
CLI utilities: parse_args, flag_value, print_usage.
use std::cli::{parse_args, flag_value}
use std::env::{args}
mut cli = parse_args(args())
mut output = flag_value(cli, "--output", "result.txt")
seeAm "Output file: " + output
std::log โ Structured Logging
Log levels: debug, info, warn, error. Configure minimum level in .ovie/aproko.toml.
use std::log::{info, warn, error, debug}
info("Server started on port 8080")
warn("Config file not found, using defaults")
error("Failed to connect to database")
debug("Processing item: " + item_id)
std::testing โ Test Framework
Assertions: assert_eq, assert_true, assert_false, assert_not_null.
use std::testing::{assert_eq, assert_true, assert_false}
fn test_add() {
assert_eq(add(2, 3), 5, "2 + 3 should equal 5")
assert_true(add(0, 0) == 0, "0 + 0 should be 0")
assert_false(add(1, 1) == 3, "1 + 1 should not be 3")
}
test_add()
seeAm "All tests passed"
std::module โ Module System (New v2.3)
Module loading, resolution, dependency graph, cache, and package manager.
use std::module::{load_module, resolve, kb_query}
// Load a module dynamically
mut mod = load_module("./plugins/my_plugin.ov")
// Query the knowledge base
mut types = kb_query({
category: "TypeInformation",
symbol_name: "add"
})
std::aproko โ Knowledge Base (New v2.3)
Persistent AI-accessible storage for type info, patterns, and reasoning rules.
use std::aproko::{store_entry, get_type_info, kb_entry_new, export_json}
// Store analysis result
mut entry = kb_entry_new(
"my_fn",
"TypeInformation",
"{\"returns\":\"Number\"}"
)
entry.symbol_name = "my_fn"
store_entry(entry)
// Query type info
mut info = get_type_info("my_fn")
// Export for AI/LLM consumption
export_json(".ovie/aproko/export.json")