Skip to content

Latest commit

 

History

History
53 lines (38 loc) · 2.53 KB

File metadata and controls

53 lines (38 loc) · 2.53 KB

maat_stdlib

Standard library sources for the Maat programming language.

Role

maat_stdlib ships .maat source files that are embedded in the maat binary at compile time and injected into every program's module graph before user code is resolved. It provides the foundational modules available under the std:: namespace, giving Maat programs access to common data structures, algorithms, and cryptographic primitives without external dependencies.

Modules

Module Contents
std::math Integer power, absolute value, min/max
std::vec Vector construction and manipulation helpers
std::map Ordered map utilities
std::set Ordered set utilities
std::string String formatting and conversion helpers
std::option Option-style pattern utilities
std::result Result-style pattern utilities
std::cmp Comparison utilities
std::num Numeric trait helpers
std::hash Rescue-Prime STARK-friendly hashing (rescue_2, rescue_4, rescue_8)

Usage

Standard library modules are available automatically; no explicit import is needed for items re-exported from the prelude. For non-prelude items:

use std::math;

fn main() {
    let x = math::pow(2, 10); // 1024
    println!("{x}");
}

The hash:: qualified path is available without an explicit use. Each hash::rescue_N call is lowered to a single Opcode::HashRescue dispatch via a maat_codegen intercept; the function must be invoked directly (first-class function-value use is not supported---the codegen intercept only fires on direct call sites):

fn main() -> Felt {
    let input: [Felt; 2] = [3_fe, 7_fe];
    let digest = hash::rescue_2(input);
    digest[0]
}

API Docs

docs.rs/maat_stdlib

Repository

github.com/maatlabs/maat. See the project README for an overview of the full compiler pipeline.