A Tour of Mighty¶
The tour walks through the canonical example programs that ship
with the compiler. Each chapter introduces one or two language
features, shows the source, explains what is interesting about it,
and tells you how to feed it to mty check.
If you have not installed the compiler yet, see ../getting-started.md.
Contents (chapters 1–15 — language fundamentals)¶
- Hello, Mighty — the smallest program.
- Types — structs, enums, type aliases, pattern matching.
- Generics — generic functions and
Option. - Errors — the
T!Esugar and?propagation. - Control flow —
for,while,loop,match. - Agents and protocols — first-class concurrent units.
- Send, ask, deadlines —
!Msg,?Msg,@duration. - Supervisors — failure boundaries.
- Arenas — scoped allocation.
- Capabilities — authority as parameters.
- Budgets — bounded resource use.
- Extern — C and JavaScript interop.
- Unsafe — raw memory, contracts, audit metadata.
- Ownership — moves, borrows, drop, arena escape, cross-agent Sendable.
- Traits — declaration, impls, dispatch,
dyn Trait, derive(Copy/Hash/Eq).
Contents (chapters 16–21 — agent surface, v0.26–v0.33)¶
- Tools and LLM providers —
@tooldecorator, typed providers, streaming. - Swarm consensus and
std.eval— multi-provider voting + regression harness. - Taint types —
Tainted[T]and the three approved exits; prompt injection as a compile error. - Observability —
std.observe+mty inspect --cost. - Computer use — Anthropic Computer Use as a capability with a typed sandbox.
- RAG and vision —
std.rag.Index+std.rag.Rag+std.llm.Imagemulti-modal pipeline (v0.33).
Examples 16–24 (macros, sandboxes, end-to-end backend / frontend
services, effect rows, agent fields) sit outside the tour
chapters because they are direct references for surfaces already
covered in earlier chapters. They live under
examples/
grouped by topic. Examples 37–40 cover post-v0.30 surfaces
(mty dap debug session in 37, diagnostic envelopes in 38,
v0.36 native binaries + extern C in 39, v0.36 T3 string editing
in 40).
Running every example¶
On Windows PowerShell:
All 40 shipped examples parse, format-roundtrip, type-check,
borrow-check, effect-check, taint-check, and run cleanly as of
v0.36. If you see anything other than ok: <path> (or the
documented MT2026 warning on 13_capabilities.mty), open an
issue.
Reading order¶
For first-time readers: start at chapter 1 and work forward. The
order follows the example files (01_*.mty through 15_*.mty),
and later chapters assume the syntax introduced earlier.
For experienced systems programmers who want the agent stuff: read chapters 6–7 (agents + send/ask), 10 (capabilities), then jump to the agent-stdlib examples 27–36 via the examples README.
Spec cross-references¶
Section numbers in this tour reference the current normative spec,
docs/spec/v1.0-rc.md (v1.0-RC5). The
historical v0.1 spec stub at
docs/spec/v0.1.md is preserved for
archaeology; do not author against it.