T81 Foundation

T81 Data Types Overview

Table of Contents

This guide introduces a curated set of T81 data types through a runnable example (examples/data_types.t81). The goal is to show how primitives, strings, and structural types behave once compiled with the t81 CLI.

Categories Covered

Category Types Highlights
Primitives i32, T81Float, T81String Basic arithmetic, floating-point adjustments, and string literals
Structural Option[T], Result[T, E] Pattern-match both constructors and inspect the canonical TISC branches

Example: examples/data_types.t81

fn demo_primitives() -> i32 { ... }
fn demo_structural() -> i32 { ... }
fn main() -> i32 { ... }

The example showcases:

Run the Demos

./build/t81 code build examples/data_types.t81 -o /tmp/data_types.tisc
./build/t81 code run /tmp/data_types.tisc

./build/t81 code build examples/fraction_demo.t81 -o /tmp/fraction_demo.tisc
./build/t81 code run /tmp/fraction_demo.tisc

./build/t81 code build examples/tensor_demo.t81 -o /tmp/tensor_demo.tisc
./build/t81 code run /tmp/tensor_demo.tisc

./build/t81 code build examples/bigint_demo.t81 -o /tmp/bigint_demo.tisc
./build/t81 code run /tmp/bigint_demo.tisc

./build/t81 code build examples/float_demo.t81 -o /tmp/float_demo.tisc
./build/t81 code run /tmp/float_demo.tisc

./build/t81 code build examples/string_demo.t81 -o /tmp/string_demo.tisc
./build/t81 code run /tmp/string_demo.tisc

./build/t81 code build examples/vector_demo.t81 -o /tmp/vector_demo.tisc
./build/t81 code run /tmp/vector_demo.tisc

./build/t81 code build examples/matrix_demo.t81 -o /tmp/matrix_demo.tisc
./build/t81 code run /tmp/matrix_demo.tisc

./build/t81 code build examples/cell_demo.t81 -o /tmp/cell_demo.tisc
./build/t81 code run /tmp/cell_demo.tisc

./build/t81 code build examples/quaternion_demo.t81 -o /tmp/quaternion_demo.tisc
./build/t81 code run /tmp/quaternion_demo.tisc

./build/t81 code build examples/high_rank_tensor_demo.t81 -o /tmp/high_rank_tensor_demo.tisc
./build/t81 code run /tmp/high_rank_tensor_demo.tisc

./build/t81 code build examples/graph_demo.t81 -o /tmp/graph_demo.tisc
./build/t81 code run /tmp/graph_demo.tisc

Use scripts/run-demos.sh (which now runs match, primitive, fraction, tensor, bigint, float, string, vector, matrix, cell, quaternion, high-rank tensor, and graph demos) to execute the entire suite in sequence.

Highlights: High-Rank Tensor and Graph Demos

Next steps

Blueprint: Handle-heavy Types (Streams / Promises / Agents)

The core handles in include/t81/types (notably T81IOStream, T81Promise<T>, and T81Agent) require future language bindings. Here is what a T81Lang demo could look like once these constructs are available:

fn stream_log() {
    let log = stream::stdout();
    log << "Starting deterministic log\n";
    log << current_time();
}

fn await_prediction() -> T81String {
    let promise: T81Promise[T81String] = dream::compute_meaning_of_life();
    return promise.await(T81Entropy::acquire_batch(64));
}

fn agent_loop(agent: T81Agent) {
    agent.observe(symbols::SELF_PRESERVATION);
    agent.act();
    let reflection = agent.reflect();
    log << "Agent intent: " << reflection.intent();
}

Enable these demos by:

  1. Extending the parser/lexer with keywords like stream::stdout, dream::compute_meaning_of_life, and coroutine syntax for await.
  2. Lowering T81Promise/T81Agent semantics to the IR with explicit entropy/fuel operands and serialization hooks so the HanoiVM can enforce deterministic accounting.
  3. Wiring the CLI demos (scripts/run-demos.sh) to compile/run these sources once the language and IR support the constructs.

For now, treat these snippets as a roadmap: they explain the control flow and thermodynamic accounting we want to expose when the remaining handle APIs are fully implemented.

You should see the CLI report “Compilation successful” followed by “Program terminated normally,” and the HanoiVM registers will contain the computed sum.

Expand the Playground