Skip to content

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)

  1. Hello, Mighty — the smallest program.
  2. Types — structs, enums, type aliases, pattern matching.
  3. Generics — generic functions and Option.
  4. Errors — the T!E sugar and ? propagation.
  5. Control flowfor, while, loop, match.
  6. Agents and protocols — first-class concurrent units.
  7. Send, ask, deadlines!Msg, ?Msg, @duration.
  8. Supervisors — failure boundaries.
  9. Arenas — scoped allocation.
  10. Capabilities — authority as parameters.
  11. Budgets — bounded resource use.
  12. Extern — C and JavaScript interop.
  13. Unsafe — raw memory, contracts, audit metadata.
  14. Ownership — moves, borrows, drop, arena escape, cross-agent Sendable.
  15. Traits — declaration, impls, dispatch, dyn Trait, derive(Copy/Hash/Eq).

Contents (chapters 16–21 — agent surface, v0.26–v0.33)

  1. Tools and LLM providers@tool decorator, typed providers, streaming.
  2. Swarm consensus and std.eval — multi-provider voting + regression harness.
  3. Taint typesTainted[T] and the three approved exits; prompt injection as a compile error.
  4. Observabilitystd.observe + mty inspect --cost.
  5. Computer use — Anthropic Computer Use as a capability with a typed sandbox.
  6. RAG and visionstd.rag.Index + std.rag.Rag + std.llm.Image multi-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

for f in examples/*.mty; do mty check "$f"; done

On Windows PowerShell:

Get-ChildItem examples/*.mty | ForEach-Object { mty check $_.FullName }

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.