Welcome to The Koru Book

This isn't like traditional programming tutorials. Instead of static examples, you're looking at living documentation — every page is backed by a real test that actually runs.

When you see a ✓, that means the code actually compiles and runs correctly. When you see ✗, you're looking at something we're still working on. This is documentation that can never drift from reality because it IS reality.

The Zen of Koru

The atom is the event. Functions are just events that forgot how to branch.

Branches are how decisions actually work. Flows are how things actually happen.

What you don't write can't break. What you don't hide can't surprise.

What you don't promise can't fail. Fail loudly, fix honestly.

Model reality, not abstractions. Let patterns emerge from events.

Complex behavior from simple rules. The AST is the program.

Zero cost at runtime. All magic at compile time. The boundary dissolves.

We built this together. Human vision, AI capability.

🟢

Working Features

Green tests (✓) are ready to learn from today

🔴

In Progress

Red tests (✗) are features we're currently building

🔵

Coming Soon

Blue tests (○) are planned features on the horizon

Suggested Learning Path

1. Start with Core Language — Learn the fundamentals of events and procs

2. Move to Control Flow — Understand how Koru programs flow with labels and continuations

3. Explore Advanced Topics — Event taps, phantom types, metacircular compilation

The Koru Book

Learn Koru through working examples. Every lesson is a real test from the compiler's regression suite.

Tests: 539
✓ 443 passing
✗ 4 failing
○ 72 planned

core language / basic syntax

4/4

core language / events flows

12/12

core language / types values

6/6

Tests for expression-based flow syntax (design under review).

core language / control flow

32/34

module system / imports

15/16

module system / namespaces

2/2

module system / packages

1/2

parser

6/6

This category defines the structure of the Koru Abstract Syntax Tree (AST) and the parsing rules.

compiler features / parser

47/48

This category provides **gold-standard testing** for Koru's parser, validating both successful parses (AST structure) and syntax error cases (precise error messages).

compiler features / compilation

16/16

compiler features / flow checker

3/3

compiler features / codegen

1/1

compiler features / emitter

3/3

compiler features / subflow

1/1

syntax / struct constructors

2/2

advanced features / comptime

46/55

Tests for compile-time evaluation and metacircular features.

advanced features / stdlib

38/46

advanced features / keyword

5/5

advanced features / phantom types

59/64

Tests for the phantom type-state system - compile-time tracking of runtime states.

advanced features / fusion

2/6

advanced features / transforms

2/2

advanced features / type system

1/1

advanced features / types

1/1

advanced features / auto proc

4/4

advanced features / subflows

7/7

advanced features / taps observers

5/7

Tests for the tap system - observer pattern for events.

advanced features / interceptors

0/4

advanced features / phantom types

0/1

advanced features / polyglot

3/8

advanced features / templating

2/4

advanced features / kernel

7/10

**Why kernels exist, what they guarantee, and why they are fast**

advanced features / testing

10/10

control flow

3/4

> Zero-cost abstractions through template expansion

runtime features

2/2

runtime features / budgeted interpreter

6/6

runtime features / purity checking

8/11

runtime features / performance

0/29

Tests for compiler optimizations and zero-cost abstractions.

runtime features / coordination

7/10

runtime features / runtime

34/34

runtime features / resource bridge

2/2

integration testing / negative tests

10/10

This directory contains tests that validate the compiler's error messages and failure modes. These tests ensure that:

integration testing / negative tests / 020 parse errors

1/1

integration testing / negative tests / 030 type errors

1/1

integration testing / negative tests / 060 compiler crashes

1/1

integration testing / bug reproduction

7/7

integration testing / validation

7/7

Tests for type checking, branch coverage, and phantom types.

stdlib / string

2/2

event globbing

4/11

examples showcase

1/1

Working examples that appear on korulang.org. These tests ensure the website never shows broken code.

examples showcase / language shootout

4/9

> **"Be within 20% of C/Zig, then optimize to beat them."**

How This Works

Every page in this book is backed by a real test in the Koru compiler's regression suite. When you see a ✓, that means the code actually compiles and runs correctly. When you see ✗, you're looking at something we're still working on.

This is living documentation — it can never drift from reality because it IS reality. The tests run on every commit.