> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apich.org/llms.txt
> Use this file to discover all available pages before exploring further.

# aevia

> A functional language for scientific computing with physical dimensions in its type system, backed by RSSN.

**Aevia** is a functional programming language for scientific computing whose type system checks physical dimensions before execution. Expressions such as `3 m + 2 s` fail at compile time with a dimensional type error, while symbolic transformations, numerical kernels, and unit metadata are supplied by **RSSN**.

> [!NOTE]
>
> Aevia maintains its own dedicated documentation platform, interactive book, standard library reference, and online playground at **[aevia.apich.org](https://aevia.apich.org/)**.

> [card] [Aevia Platform & Docs](https://aevia.apich.org/)
>
> Interactive Book, Standard Library reference, playground, and package registry.

> [card] [The Aevia Book](https://aevia.apich.org/book?lang=en)
>
> Step-by-step language manual with runnable exercises and dimensional typing guides.

> [card] [Standard Library Reference](https://aevia.apich.org/stdlib?lang=en)
>
> All 41 standard library modules, signatures, dimensions, and examples.

> [card] [Project Homepage & GitHub](https://github.com/Apich-Organization/aevia)
>
> Source repository and [apich.org/projects/aevia](https://apich.org/projects/aevia/) overview.

## Dual-Workspace & Compiler Architecture

Aevia is structured across two Cargo workspaces plus the sibling `rssn` repository. Separating the **Language Workspace** (15 crates) from the **Platform Workspace** (6 crates) ensures the web registry (`aevia-registry-server`) and package CLI (`aevia-pkg`) never link the heavy numerical engine.

```mermaid theme={null}
flowchart LR
    Src["Source (.aev)"] --> Lex["aevia-syntax + aevia-resolve"]
    Lex --> Check["aevia-types + aevia-dim (DimUnifier)"]
    Check --> Cache[".aevi v4 Disk Cache (bincode-next 3.2 + FNV-1a)"]
    Check --> IR["aevia-ir (ANF + Closure Conversion + BooleanFacts)"]
    IR --> Eval["aevia-core (Trampolined IR + Cranelift @jit + wgpu + Rayon)"]
    RSSN["rssn (Kernel Manifest + 41 stdlib kernels)"] --> Check
    RSSN --> Eval
```

## Repository Structure

| Crate / Workspace | Role |
| - | - |
| `crates/aevia-dim`, `aevia-syntax`, `aevia-types` | Lexer/parser, physical dimension algebra (`DimUnifier`), row/shape typing, and RSSN overload resolution (`OpKey`) |
| `crates/aevia-ir` & `crates/aevia-core` | ANF lowering, closure conversion, `.aevi` v4 cache, slot-frame evaluator, Cranelift `@jit`, `wgpu`, Rayon, and DAP debugger |
| `crates/aevia-rssn` & `crates/aevia-std` | RSSN Kernel Manifest bridge (`BLAKE3` hash) and 41 standard library modules (`linalg`, `ode`, `pde`, `fft`, `stats`, `sim`, etc.) |
| `crates/aevia-analysis` & `crates/aevia-lsp` | Protocol-agnostic semantic analysis (`AnalysisCache`, cursor index, actions) and JSON-RPC stdio language server |
| `crates/aevia-fmt`, `aevia-doc`, `aevia-lint`, `aevia-cli` | Formatter, non-executing documentation builder, linter (`@allow`/`@warn`/`@deny`/`@forbid`), and `aevia` CLI/REPL |
| `platform/` (6 crates) | Separate Cargo workspace for `aevia-pkg` (signed publishing & lockfiles), `aevia-registry-server`, PostgreSQL store, and Leptos SSR |

## Toolchain & Commands

| Binary / Command | Purpose | Notes |
| - | - | - |
| `aevia check` / `run` / `test` | Type- and dimension-check, execute, or test | Drives `aevia-core/src/driver.rs` consistently |
| `aevia` (REPL) | Interactive prompt (`:type`, `:rssn-backend`) | Inspects symbolic forms and dimensions live |
| `aevia fmt` / `doc` / `lint` | Format, build static docs, and lint modules | `doc` parses source as data without executing |
| `aevia devices` / `toolchain` | Inspect SIMD/`wgpu` devices and manage channels | Supports `stable` and `nightly` channels |
| `aevia-lsp` & `aevia dap` | IDE language server and debug adapter | Diagnostics, navigation, and breakpoints |
| `aevia-pkg` | Package manager and registry client | `aevia.toml` manifests, lockfiles, signed publishing |

## Quick Example (`examples/kinematics.aev`)

```text theme={null}
module Kinematics

let g = 9.80665 m/s^2

fn fall_time(h: Real[L]): Real[T] = sqrt(2 * h / g)

fn main(): IO Unit = do
    let h = 20.0 m
    println("fall time from {h} = {fall_time(h)}")
    match approx(fall_time(h)) with
    | Ok(t) -> println("numerically       = {t}")
    | Err(e) -> println("approx failed: {e}")
```

`fall_time` requires a length `Real[L]` and returns a time `Real[T]`. `sqrt(2 * h / g)` stays exact symbolically until `approx` explicitly converts it to floating-point.


## Related topics

- [Quickstart](https://docs.apich.org/quickstart.md)
- [Stack Architecture & Project Map](https://docs.apich.org/guides/architecture.md)
- [Apich Organization Documentation](https://docs.apich.org/index.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.