<!-- Examples · Tin · https://tin.ad/docs/examples/ · generated from the built page -->

# Examples

Every file in `examples/`. `npm test` runs each one and checks its output against the one shown on its page.

## The language

- [01-hello](https://tin.ad/docs/examples/01-hello/) The smallest Tin program.
- [02-fizzbuzz](https://tin.ad/docs/examples/02-fizzbuzz/) Functions, ranges, and `if` as an expression.
- [03-shapes](https://tin.ad/docs/examples/03-shapes/) Sum types and exhaustive `match`.
- [04-pipelines](https://tin.ad/docs/examples/04-pipelines/) Pipelines and methods.
- [05-errors](https://tin.ad/docs/examples/05-errors/) No null, no exceptions.
- [06-generics](https://tin.ad/docs/examples/06-generics/) Generics are monomorphised: Stack<int> and Stack<string> each compile to their own specialised WebAssembly, with no boxing and no runtime type checks.
- [07-tree](https://tin.ad/docs/examples/07-tree/) A recursive sum type: an immutable binary search tree.
- [08-closures](https://tin.ad/docs/examples/08-closures/) Functions are values.
- [09-concurrency](https://tin.ad/docs/examples/09-concurrency/) The event loop, without coloured functions.
- [10-mandelbrot](https://tin.ad/docs/examples/10-mandelbrot/) Floating-point number crunching, drawn in ASCII.
- [11-sieve](https://tin.ad/docs/examples/11-sieve/) Arrays and tight loops: the sieve of Eratosthenes.
- [12-words](https://tin.ad/docs/examples/12-words/) Strings and maps: count the words in a text.
- [13-bank](https://tin.ad/docs/examples/13-bank/) Structs with methods, and errors as ordinary values.
- [14-life](https://tin.ad/docs/examples/14-life/) Conway's Game of Life on a small torus.
- [15-values](https://tin.ad/docs/examples/15-values/) Arrays and structs are values, like numbers.
- [16-tests](https://tin.ad/docs/examples/16-tests/) Tests live next to the code they test.
- [17-numbers](https://tin.ad/docs/examples/17-numbers/) Numbers never wrap around silently.
- [18-rates](https://tin.ad/docs/examples/18-rates/) Frequency is a unit, like Duration.
- [19-equality](https://tin.ad/docs/examples/19-equality/) == compares values, not identities: two arrays, structs or enums are equal when their parts are.
- [20-timestamps](https://tin.ad/docs/examples/20-timestamps/) i64 is a 64-bit integer, for values that outgrow int's 32 bits: nanosecond timestamps, byte counts, big counters.
- [21-loops](https://tin.ad/docs/examples/21-loops/) Three loops: `for x in xs`, `for i, x in xs` (with the index), and `loop { }`, which runs until a `break` or `return`.
- [22-tuples](https://tin.ad/docs/examples/22-tuples/) Tuples group a few values without declaring a type: (lo, hi), ("x", 1.5).
- [23-bits](https://tin.ad/docs/examples/23-bits/) Bits, for registers and flags: & | ^ on int and i64, and x.shl(n) / x.shr(n).
- [24-patterns](https://tin.ad/docs/examples/24-patterns/) Nested patterns.
- [25-tasks](https://tin.ad/docs/examples/25-tasks/) Structured concurrency: tasks have owners, and waiting has limits.
- [26-traits](https://tin.ad/docs/examples/26-traits/) Traits: say what a generic function needs, and get the error at the call.
- [27-order](https://tin.ad/docs/examples/27-order/) The standard library's traits: Ord, Show and Eq.
- [28-chars](https://tin.ad/docs/examples/28-chars/) char: one Unicode character.
- [29-iterators](https://tin.ad/docs/examples/29-iterators/) for over your own types.
- [anthropic/batch](https://tin.ad/docs/examples/anthropic/batch/) The Anthropic API beyond one agent turn, from Tin: count tokens, list models, send a Message Batch, wait for it and read the results.
- [anthropic/editor](https://tin.ad/docs/examples/anthropic/editor/) The text editor tool (text_editor_20250728): Claude views and edits files under ./workspace.
- [anthropic/files](https://tin.ad/docs/examples/anthropic/files/) The Files API: upload once, then refer to the file by id.
- [anthropic/memory](https://tin.ad/docs/examples/anthropic/memory/) Claude's memory tool (memory_20250818): the model asks for file operations under /memories and this program runs them, in one JSON file next to it.
- [anthropic/research](https://tin.ad/docs/examples/anthropic/research/) An agent with tools Anthropic runs: web search, web fetch and code execution, plus an MCP server.
- [cli/hello](https://tin.ad/docs/examples/cli/hello/) args() and exit(code): a command-line program.
- [interop/main](https://tin.ad/docs/examples/interop/main/) Calling JavaScript from Tin.
- [learn/00-readme/hero](https://tin.ad/docs/examples/learn/00-readme/hero/)
- [learn/01-hello/greet](https://tin.ad/docs/examples/learn/01-hello/greet/) A line starting with // is a comment.
- [learn/01-hello/hello](https://tin.ad/docs/examples/learn/01-hello/hello/)
- [learn/01-hello/mix.fails](https://tin.ad/docs/examples/learn/01-hello/mix.fails/)
- [learn/01-hello/short](https://tin.ad/docs/examples/learn/01-hello/short/)
- [learn/01-hello/task-1.solution](https://tin.ad/docs/examples/learn/01-hello/task-1.solution/)
- [learn/01-hello/task-2.fails](https://tin.ad/docs/examples/learn/01-hello/task-2.fails/)
- [learn/01-hello/task-2.solution](https://tin.ad/docs/examples/learn/01-hello/task-2.solution/)
- [learn/01-hello/task-3.solution](https://tin.ad/docs/examples/learn/01-hello/task-3.solution/)
- [learn/01-hello/toplevel.fails](https://tin.ad/docs/examples/learn/01-hello/toplevel.fails/)
- [learn/01-hello/typo.fails](https://tin.ad/docs/examples/learn/01-hello/typo.fails/)
- [learn/02-values/bools](https://tin.ad/docs/examples/learn/02-values/bools/)
- [learn/02-values/char-vs-string.fails](https://tin.ad/docs/examples/learn/02-values/char-vs-string.fails/)
- [learn/02-values/chars](https://tin.ad/docs/examples/learn/02-values/chars/)
- [learn/02-values/format](https://tin.ad/docs/examples/learn/02-values/format/)
- [learn/02-values/i64](https://tin.ad/docs/examples/learn/02-values/i64/)
- [learn/02-values/let-reassign.fails](https://tin.ad/docs/examples/learn/02-values/let-reassign.fails/)
- [learn/02-values/let-var](https://tin.ad/docs/examples/learn/02-values/let-var/)
- [learn/02-values/no-mixing.fails](https://tin.ad/docs/examples/learn/02-values/no-mixing.fails/)
- [learn/02-values/numbers](https://tin.ad/docs/examples/learn/02-values/numbers/)
- [learn/02-values/overflow.panics](https://tin.ad/docs/examples/learn/02-values/overflow.panics/)
- [learn/02-values/strings](https://tin.ad/docs/examples/learn/02-values/strings/)
- [learn/02-values/task-1.solution](https://tin.ad/docs/examples/learn/02-values/task-1.solution/)
- [learn/02-values/task-2.fails](https://tin.ad/docs/examples/learn/02-values/task-2.fails/)
- [learn/02-values/task-2.solution](https://tin.ad/docs/examples/learn/02-values/task-2.solution/)
- [learn/02-values/task-3.solution](https://tin.ad/docs/examples/learn/02-values/task-3.solution/)
- [learn/02-values/types](https://tin.ad/docs/examples/learn/02-values/types/)
- [learn/02-values/wrong-type.fails](https://tin.ad/docs/examples/learn/02-values/wrong-type.fails/)
- [learn/03-functions/arity.fails](https://tin.ad/docs/examples/learn/03-functions/arity.fails/)
- [learn/03-functions/arrow](https://tin.ad/docs/examples/learn/03-functions/arrow/)
- [learn/03-functions/define](https://tin.ad/docs/examples/learn/03-functions/define/) fn name(parameter: type, ...): result type { body }
- [learn/03-functions/missing-value.fails](https://tin.ad/docs/examples/learn/03-functions/missing-value.fails/)
- [learn/03-functions/no-result](https://tin.ad/docs/examples/learn/03-functions/no-result/) No result type: the function does something instead of computing a value.
- [learn/03-functions/param-types.fails](https://tin.ad/docs/examples/learn/03-functions/param-types.fails/)
- [learn/03-functions/recursion](https://tin.ad/docs/examples/learn/03-functions/recursion/) A function can call itself.
- [learn/03-functions/return](https://tin.ad/docs/examples/learn/03-functions/return/)
- [learn/03-functions/task-1.solution](https://tin.ad/docs/examples/learn/03-functions/task-1.solution/)
- [learn/03-functions/task-2.solution](https://tin.ad/docs/examples/learn/03-functions/task-2.solution/) Divisible by 4, except centuries, except every 400 years.
- [learn/03-functions/task-3.fails](https://tin.ad/docs/examples/learn/03-functions/task-3.fails/)
- [learn/03-functions/task-3.solution](https://tin.ad/docs/examples/learn/03-functions/task-3.solution/)
- [learn/04-control/block-value](https://tin.ad/docs/examples/learn/04-control/block-value/)
- [learn/04-control/break-continue](https://tin.ad/docs/examples/learn/04-control/break-continue/)
- [learn/04-control/for-items](https://tin.ad/docs/examples/learn/04-control/for-items/)
- [learn/04-control/for-range](https://tin.ad/docs/examples/learn/04-control/for-range/)
- [learn/04-control/if](https://tin.ad/docs/examples/learn/04-control/if/)
- [learn/04-control/if-value](https://tin.ad/docs/examples/learn/04-control/if-value/)
- [learn/04-control/loop](https://tin.ad/docs/examples/learn/04-control/loop/)
- [learn/04-control/no-truthy.fails](https://tin.ad/docs/examples/learn/04-control/no-truthy.fails/)
- [learn/04-control/task-1.solution](https://tin.ad/docs/examples/learn/04-control/task-1.solution/)
- [learn/04-control/task-2.solution](https://tin.ad/docs/examples/learn/04-control/task-2.solution/)
- [learn/04-control/task-3.solution](https://tin.ad/docs/examples/learn/04-control/task-3.solution/)
- [learn/04-control/while](https://tin.ad/docs/examples/learn/04-control/while/)
- [learn/05-structs/change](https://tin.ad/docs/examples/learn/05-structs/change/)
- [learn/05-structs/equality](https://tin.ad/docs/examples/learn/05-structs/equality/)
- [learn/05-structs/methods](https://tin.ad/docs/examples/learn/05-structs/methods/)
- [learn/05-structs/missing-field.fails](https://tin.ad/docs/examples/learn/05-structs/missing-field.fails/)
- [learn/05-structs/nested](https://tin.ad/docs/examples/learn/05-structs/nested/)
- [learn/05-structs/shorthand](https://tin.ad/docs/examples/learn/05-structs/shorthand/)
- [learn/05-structs/struct](https://tin.ad/docs/examples/learn/05-structs/struct/) A struct type: a name for a group of named fields.
- [learn/05-structs/task-1.solution](https://tin.ad/docs/examples/learn/05-structs/task-1.solution/)
- [learn/05-structs/task-2.solution](https://tin.ad/docs/examples/learn/05-structs/task-2.solution/)
- [learn/05-structs/task-3.solution](https://tin.ad/docs/examples/learn/05-structs/task-3.solution/)
- [learn/05-structs/tuples](https://tin.ad/docs/examples/learn/05-structs/tuples/) A tuple groups a few values without declaring a type.
- [learn/06-enums/forgot.fails](https://tin.ad/docs/examples/learn/06-enums/forgot.fails/)
- [learn/06-enums/guards](https://tin.ad/docs/examples/learn/06-enums/guards/)
- [learn/06-enums/payload](https://tin.ad/docs/examples/learn/06-enums/payload/) Each variant can carry its own data.
- [learn/06-enums/positional](https://tin.ad/docs/examples/learn/06-enums/positional/) Variants can also carry values by position, like a function call.
- [learn/06-enums/simple](https://tin.ad/docs/examples/learn/06-enums/simple/) A sum type: a value that is exactly one of these.
- [learn/06-enums/task-1.solution](https://tin.ad/docs/examples/learn/06-enums/task-1.solution/)
- [learn/06-enums/task-2.solution](https://tin.ad/docs/examples/learn/06-enums/task-2.solution/) A sum type can contain itself: an expression is a number, or two expressions combined.
- [learn/06-enums/task-3.solution](https://tin.ad/docs/examples/learn/06-enums/task-3.solution/)
- [learn/06-enums/values](https://tin.ad/docs/examples/learn/06-enums/values/) match works on ints and strings too.
- [learn/07-errors/no-null.fails](https://tin.ad/docs/examples/learn/07-errors/no-null.fails/)
- [learn/07-errors/option](https://tin.ad/docs/examples/learn/07-errors/option/) Option<T> is Some(value) or None.
- [learn/07-errors/or](https://tin.ad/docs/examples/learn/07-errors/or/)
- [learn/07-errors/own-error](https://tin.ad/docs/examples/learn/07-errors/own-error/) The error can be your own sum type, so callers can tell the failures apart.
- [learn/07-errors/panic.panics](https://tin.ad/docs/examples/learn/07-errors/panic.panics/) panic is for bugs: things that should never happen.
- [learn/07-errors/question](https://tin.ad/docs/examples/learn/07-errors/question/)
- [learn/07-errors/question-option](https://tin.ad/docs/examples/learn/07-errors/question-option/) ? works on Option too, in a function that returns an Option.
- [learn/07-errors/result](https://tin.ad/docs/examples/learn/07-errors/result/) Result<T, E> is Ok(value) or Err(error): an operation that can fail, and why.
- [learn/07-errors/task-1.solution](https://tin.ad/docs/examples/learn/07-errors/task-1.solution/)
- [learn/07-errors/task-2.solution](https://tin.ad/docs/examples/learn/07-errors/task-2.solution/)
- [learn/07-errors/task-3.solution](https://tin.ad/docs/examples/learn/07-errors/task-3.solution/)
- [learn/08-collections/arrays](https://tin.ad/docs/examples/learn/08-collections/arrays/)
- [learn/08-collections/change](https://tin.ad/docs/examples/learn/08-collections/change/)
- [learn/08-collections/empty](https://tin.ad/docs/examples/learn/08-collections/empty/)
- [learn/08-collections/empty.fails](https://tin.ad/docs/examples/learn/08-collections/empty.fails/)
- [learn/08-collections/maps](https://tin.ad/docs/examples/learn/08-collections/maps/)
- [learn/08-collections/one-type.fails](https://tin.ad/docs/examples/learn/08-collections/one-type.fails/)
- [learn/08-collections/out-of-bounds.panics](https://tin.ad/docs/examples/learn/08-collections/out-of-bounds.panics/)
- [learn/08-collections/sets](https://tin.ad/docs/examples/learn/08-collections/sets/)
- [learn/08-collections/sort](https://tin.ad/docs/examples/learn/08-collections/sort/)
- [learn/08-collections/task-1.solution](https://tin.ad/docs/examples/learn/08-collections/task-1.solution/)
- [learn/08-collections/task-2.solution](https://tin.ad/docs/examples/learn/08-collections/task-2.solution/)
- [learn/08-collections/task-3.solution](https://tin.ad/docs/examples/learn/08-collections/task-3.solution/)
- [learn/09-closures/capture-var.fails](https://tin.ad/docs/examples/learn/09-closures/capture-var.fails/)
- [learn/09-closures/closure](https://tin.ad/docs/examples/learn/09-closures/closure/)
- [learn/09-closures/fn-values](https://tin.ad/docs/examples/learn/09-closures/fn-values/)
- [learn/09-closures/map-filter](https://tin.ad/docs/examples/learn/09-closures/map-filter/)
- [learn/09-closures/pipe](https://tin.ad/docs/examples/learn/09-closures/pipe/)
- [learn/09-closures/reduce](https://tin.ad/docs/examples/learn/09-closures/reduce/)
- [learn/09-closures/sort-by](https://tin.ad/docs/examples/learn/09-closures/sort-by/)
- [learn/09-closures/task-1.solution](https://tin.ad/docs/examples/learn/09-closures/task-1.solution/)
- [learn/09-closures/task-2.solution](https://tin.ad/docs/examples/learn/09-closures/task-2.solution/)
- [learn/09-closures/task-3.solution](https://tin.ad/docs/examples/learn/09-closures/task-3.solution/) Returns a function.
- [learn/10-generics/generic-sum](https://tin.ad/docs/examples/learn/10-generics/generic-sum/) A generic sum type: a tree of anything.
- [learn/10-generics/generic-type](https://tin.ad/docs/examples/learn/10-generics/generic-type/) Types can take parameters too.
- [learn/10-generics/infer.fails](https://tin.ad/docs/examples/learn/10-generics/infer.fails/)
- [learn/10-generics/largest](https://tin.ad/docs/examples/learn/10-generics/largest/)
- [learn/10-generics/not-comparable.fails](https://tin.ad/docs/examples/learn/10-generics/not-comparable.fails/)
- [learn/10-generics/ord](https://tin.ad/docs/examples/learn/10-generics/ord/)
- [learn/10-generics/task-1.solution](https://tin.ad/docs/examples/learn/10-generics/task-1.solution/)
- [learn/10-generics/task-2.solution](https://tin.ad/docs/examples/learn/10-generics/task-2.solution/)
- [learn/10-generics/task-3.solution](https://tin.ad/docs/examples/learn/10-generics/task-3.solution/)
- [learn/10-generics/traits](https://tin.ad/docs/examples/learn/10-generics/traits/)
- [learn/10-generics/traits-missing.fails](https://tin.ad/docs/examples/learn/10-generics/traits-missing.fails/)
- [learn/10-generics/why](https://tin.ad/docs/examples/learn/10-generics/why/) Without generics you'd write the same function once per type.
- [learn/11-values/copy](https://tin.ad/docs/examples/learn/11-values/copy/)
- [learn/11-values/copy-struct](https://tin.ad/docs/examples/learn/11-values/copy-struct/)
- [learn/11-values/inout](https://tin.ad/docs/examples/learn/11-values/inout/)
- [learn/11-values/inout-let.fails](https://tin.ad/docs/examples/learn/11-values/inout-let.fails/)
- [learn/11-values/inout-method](https://tin.ad/docs/examples/learn/11-values/inout-method/)
- [learn/11-values/iterator](https://tin.ad/docs/examples/learn/11-values/iterator/)
- [learn/11-values/param](https://tin.ad/docs/examples/learn/11-values/param/) A parameter is a copy too.
- [learn/11-values/param-let.fails](https://tin.ad/docs/examples/learn/11-values/param-let.fails/)
- [learn/11-values/task-1.solution](https://tin.ad/docs/examples/learn/11-values/task-1.solution/)
- [learn/11-values/task-2.solution](https://tin.ad/docs/examples/learn/11-values/task-2.solution/)
- [learn/11-values/task-3.solution](https://tin.ad/docs/examples/learn/11-values/task-3.solution/)
- [learn/12-units/convert](https://tin.ad/docs/examples/learn/12-units/convert/)
- [learn/12-units/durations](https://tin.ad/docs/examples/learn/12-units/durations/)
- [learn/12-units/freq-mix.fails](https://tin.ad/docs/examples/learn/12-units/freq-mix.fails/)
- [learn/12-units/frequency](https://tin.ad/docs/examples/learn/12-units/frequency/)
- [learn/12-units/mix.fails](https://tin.ad/docs/examples/learn/12-units/mix.fails/)
- [learn/12-units/sleep](https://tin.ad/docs/examples/learn/12-units/sleep/)
- [learn/12-units/task-1.solution](https://tin.ad/docs/examples/learn/12-units/task-1.solution/)
- [learn/12-units/task-2.solution](https://tin.ad/docs/examples/learn/12-units/task-2.solution/)
- [learn/12-units/task-3.solution](https://tin.ad/docs/examples/learn/12-units/task-3.solution/) Waits 100ms, then 200ms, then 400ms ...
- [learn/13-modules/arm](https://tin.ad/docs/examples/learn/13-modules/arm/)
- [learn/13-modules/lib/dates](https://tin.ad/docs/examples/learn/13-modules/lib/dates/)
- [learn/13-modules/lib/dates2](https://tin.ad/docs/examples/learn/13-modules/lib/dates2/)
- [learn/13-modules/lib/joints](https://tin.ad/docs/examples/learn/13-modules/lib/joints/) lib/joints.tin: a file of types and functions for other files to use.
- [learn/13-modules/lib/money](https://tin.ad/docs/examples/learn/13-modules/lib/money/)
- [learn/13-modules/lib/report](https://tin.ad/docs/examples/learn/13-modules/lib/report/) lib/report.tin: it uses Joint, so it imports joints.tin itself.
- [learn/13-modules/lib/temps](https://tin.ad/docs/examples/learn/13-modules/lib/temps/)
- [learn/13-modules/task-1.solution](https://tin.ad/docs/examples/learn/13-modules/task-1.solution/)
- [learn/13-modules/task-2.fails](https://tin.ad/docs/examples/learn/13-modules/task-2.fails/)
- [learn/13-modules/task-2.solution](https://tin.ad/docs/examples/learn/13-modules/task-2.solution/) dates2.tin is dates.tin with its function renamed to dayLabel.
- [learn/13-modules/twice.fails](https://tin.ad/docs/examples/learn/13-modules/twice.fails/)
- [learn/14-tests/assert.test](https://tin.ad/docs/examples/learn/14-tests/assert.test/)
- [learn/14-tests/beside-main](https://tin.ad/docs/examples/learn/14-tests/beside-main/)
- [learn/14-tests/beside-main.test](https://tin.ad/docs/examples/learn/14-tests/beside-main.test/)
- [learn/14-tests/failing.test](https://tin.ad/docs/examples/learn/14-tests/failing.test/)
- [learn/14-tests/first.test](https://tin.ad/docs/examples/learn/14-tests/first.test/)
- [learn/14-tests/rotted.fails](https://tin.ad/docs/examples/learn/14-tests/rotted.fails/)
- [learn/14-tests/task-1.solution.test](https://tin.ad/docs/examples/learn/14-tests/task-1.solution.test/)
- [learn/14-tests/task-2.solution.test](https://tin.ad/docs/examples/learn/14-tests/task-2.solution.test/)
- [learn/15-first-agent/hello](https://tin.ad/docs/examples/learn/15-first-agent/hello/)
- [learn/15-first-agent/local](https://tin.ad/docs/examples/learn/15-first-agent/local/)
- [learn/15-first-agent/memory](https://tin.ad/docs/examples/learn/15-first-agent/memory/)
- [learn/15-first-agent/task-1.solution](https://tin.ad/docs/examples/learn/15-first-agent/task-1.solution/)
- [learn/15-first-agent/task-2.solution](https://tin.ad/docs/examples/learn/15-first-agent/task-2.solution/)
- [learn/15-first-agent/trace](https://tin.ad/docs/examples/learn/15-first-agent/trace/) run: --trace
- [learn/15-first-agent/typed](https://tin.ad/docs/examples/learn/15-first-agent/typed/)
- [learn/16-tools/events](https://tin.ad/docs/examples/learn/16-tools/events/)
- [learn/16-tools/failing-tool](https://tin.ad/docs/examples/learn/16-tools/failing-tool/)
- [learn/16-tools/first-tool](https://tin.ad/docs/examples/learn/16-tools/first-tool/)
- [learn/16-tools/generic.fails](https://tin.ad/docs/examples/learn/16-tools/generic.fails/)
- [learn/16-tools/not-data.fails](https://tin.ad/docs/examples/learn/16-tools/not-data.fails/)
- [learn/16-tools/schema.tools](https://tin.ad/docs/examples/learn/16-tools/schema.tools/)
- [learn/16-tools/task-1.solution](https://tin.ad/docs/examples/learn/16-tools/task-1.solution/)
- [learn/16-tools/task-2.solution.tools](https://tin.ad/docs/examples/learn/16-tools/task-2.solution.tools/)
- [learn/17-typed-replies/float.fails](https://tin.ad/docs/examples/learn/17-typed-replies/float.fails/)
- [learn/17-typed-replies/order](https://tin.ad/docs/examples/learn/17-typed-replies/order/)
- [learn/17-typed-replies/small](https://tin.ad/docs/examples/learn/17-typed-replies/small/)
- [learn/17-typed-replies/task-1.solution](https://tin.ad/docs/examples/learn/17-typed-replies/task-1.solution/)
- [learn/17-typed-replies/task-2.solution](https://tin.ad/docs/examples/learn/17-typed-replies/task-2.solution/)
- [learn/17-typed-replies/try](https://tin.ad/docs/examples/learn/17-typed-replies/try/)
- [learn/17-typed-replies/wrapped](https://tin.ad/docs/examples/learn/17-typed-replies/wrapped/)
- [learn/18-approval/approve](https://tin.ad/docs/examples/learn/18-approval/approve/)
- [learn/18-approval/approve-yes](https://tin.ad/docs/examples/learn/18-approval/approve-yes/) run: --yes
- [learn/18-approval/approved](https://tin.ad/docs/examples/learn/18-approval/approved/) run: --yes
- [learn/18-approval/denied](https://tin.ad/docs/examples/learn/18-approval/denied/)
- [learn/18-approval/direct.fails](https://tin.ad/docs/examples/learn/18-approval/direct.fails/)
- [learn/18-approval/sneaky.fails](https://tin.ad/docs/examples/learn/18-approval/sneaky.fails/)
- [learn/18-approval/task-1.solution](https://tin.ad/docs/examples/learn/18-approval/task-1.solution/) run: --yes
- [learn/18-approval/task-2.solution](https://tin.ad/docs/examples/learn/18-approval/task-2.solution/)
- [learn/19-capabilities/fetch.caps](https://tin.ad/docs/examples/learn/19-capabilities/fetch.caps/)
- [learn/19-capabilities/reach.caps](https://tin.ad/docs/examples/learn/19-capabilities/reach.caps/) run: --reach charge
- [learn/19-capabilities/shop.caps](https://tin.ad/docs/examples/learn/19-capabilities/shop.caps/)
- [learn/19-capabilities/task-1.solution.caps](https://tin.ad/docs/examples/learn/19-capabilities/task-1.solution.caps/)
- [learn/19-capabilities/task-2.solution.caps](https://tin.ad/docs/examples/learn/19-capabilities/task-2.solution.caps/)
- [learn/20-teams/critic](https://tin.ad/docs/examples/learn/20-teams/critic/)
- [learn/20-teams/pipeline](https://tin.ad/docs/examples/learn/20-teams/pipeline/)
- [learn/20-teams/sub-agent](https://tin.ad/docs/examples/learn/20-teams/sub-agent/)
- [learn/20-teams/task-1.solution](https://tin.ad/docs/examples/learn/20-teams/task-1.solution/)
- [learn/20-teams/task-2.solution](https://tin.ad/docs/examples/learn/20-teams/task-2.solution/)
- [learn/21-concurrency/agents](https://tin.ad/docs/examples/learn/21-concurrency/agents/)
- [learn/21-concurrency/budget](https://tin.ad/docs/examples/learn/21-concurrency/budget/)
- [learn/21-concurrency/precedence.fails](https://tin.ad/docs/examples/learn/21-concurrency/precedence.fails/)
- [learn/21-concurrency/spawn](https://tin.ad/docs/examples/learn/21-concurrency/spawn/)
- [learn/21-concurrency/stop](https://tin.ad/docs/examples/learn/21-concurrency/stop/)
- [learn/21-concurrency/task-1.solution](https://tin.ad/docs/examples/learn/21-concurrency/task-1.solution/)
- [learn/21-concurrency/task-2.solution](https://tin.ad/docs/examples/learn/21-concurrency/task-2.solution/)
- [learn/21-concurrency/within](https://tin.ad/docs/examples/learn/21-concurrency/within/)
- [learn/22-code-as-action/escape](https://tin.ad/docs/examples/learn/22-code-as-action/escape/)
- [learn/22-code-as-action/forever](https://tin.ad/docs/examples/learn/22-code-as-action/forever/)
- [learn/22-code-as-action/task-1.solution](https://tin.ad/docs/examples/learn/22-code-as-action/task-1.solution/)
- [learn/22-code-as-action/task-2.solution](https://tin.ad/docs/examples/learn/22-code-as-action/task-2.solution/)
- [learn/22-code-as-action/typo](https://tin.ad/docs/examples/learn/22-code-as-action/typo/)
- [learn/22-code-as-action/weather](https://tin.ad/docs/examples/learn/22-code-as-action/weather/) run: --replay tests/tapes/agents-09-code.json
- [learn/23-replay/calc](https://tin.ad/docs/examples/learn/23-replay/calc/) run: --replay tests/tapes/agents-05-claude.json
- [learn/23-replay/changed.panics](https://tin.ad/docs/examples/learn/23-replay/changed.panics/) run: --replay tests/tapes/agents-05-claude.json
- [learn/23-replay/dice](https://tin.ad/docs/examples/learn/23-replay/dice/) run: --replay examples/learn/23-replay/dice.tape.json
- [learn/23-replay/regression.test](https://tin.ad/docs/examples/learn/23-replay/regression.test/) run: --replay tests/tapes/agents-05-claude.json
- [learn/23-replay/task-1.solution](https://tin.ad/docs/examples/learn/23-replay/task-1.solution/) run: --replay examples/learn/23-replay/coins.tape.json
- [learn/23-replay/task-2.solution.test](https://tin.ad/docs/examples/learn/23-replay/task-2.solution.test/) run: --replay tests/tapes/agents-05-claude.json
- [learn/24-models/budget](https://tin.ad/docs/examples/learn/24-models/budget/)
- [learn/24-models/claude](https://tin.ad/docs/examples/learn/24-models/claude/) run: --replay tests/tapes/agents-05-claude.json
- [learn/24-models/swap](https://tin.ad/docs/examples/learn/24-models/swap/)
- [learn/24-models/task-1.solution](https://tin.ad/docs/examples/learn/24-models/task-1.solution/)
- [learn/24-models/task-2](https://tin.ad/docs/examples/learn/24-models/task-2/)
- [learn/24-models/task-2.solution](https://tin.ad/docs/examples/learn/24-models/task-2.solution/)
- [learn/25-js-interop/data](https://tin.ad/docs/examples/learn/25-js-interop/data/)
- [learn/25-js-interop/hello-js](https://tin.ad/docs/examples/learn/25-js-interop/hello-js/)
- [learn/25-js-interop/missing.panics](https://tin.ad/docs/examples/learn/25-js-interop/missing.panics/)
- [learn/25-js-interop/node](https://tin.ad/docs/examples/learn/25-js-interop/node/)
- [learn/25-js-interop/task-1.solution](https://tin.ad/docs/examples/learn/25-js-interop/task-1.solution/)
- [learn/25-js-interop/task-2.solution](https://tin.ad/docs/examples/learn/25-js-interop/task-2.solution/) run: --yes
- [learn/25-js-interop/throws](https://tin.ad/docs/examples/learn/25-js-interop/throws/)
- [learn/25-js-interop/tool.fails](https://tin.ad/docs/examples/learn/25-js-interop/tool.fails/)
- [learn/25-js-interop/wrong-type.panics](https://tin.ad/docs/examples/learn/25-js-interop/wrong-type.panics/)
- [learn/26-fleet/fleet](https://tin.ad/docs/examples/learn/26-fleet/fleet/) run: --replay tests/tapes/agents-08-fleet.json --yes
- [learn/26-fleet/fleet.caps](https://tin.ad/docs/examples/learn/26-fleet/fleet.caps/)
- [learn/26-fleet/task-1.solution.test](https://tin.ad/docs/examples/learn/26-fleet/task-1.solution.test/)
- [learn/26-fleet/task-2.solution.caps](https://tin.ad/docs/examples/learn/26-fleet/task-2.solution.caps/) run: --reach scrap
- [learn/27-cli/greet](https://tin.ad/docs/examples/learn/27-cli/greet/)
- [learn/27-cli/messy](https://tin.ad/docs/examples/learn/27-cli/messy/)
- [learn/27-cli/new-project](https://tin.ad/docs/examples/learn/27-cli/new-project/) hello: a Tin program with one agent.
- [learn/27-cli/tally](https://tin.ad/docs/examples/learn/27-cli/tally/) Reads numbers, one per line, until a blank line.
- [learn/27-cli/task-1.solution](https://tin.ad/docs/examples/learn/27-cli/task-1.solution/)
- [learn/27-cli/task-2.solution](https://tin.ad/docs/examples/learn/27-cli/task-2.solution/) A to-do list driven by commands: add <text>, done <number>, list, quit.
- [learn/28-browser/shop](https://tin.ad/docs/examples/learn/28-browser/shop/)
- [learn/29-voice/called.fails](https://tin.ad/docs/examples/learn/29-voice/called.fails/)
- [learn/29-voice/handlers](https://tin.ad/docs/examples/learn/29-voice/handlers/)
- [learn/29-voice/listen.caps](https://tin.ad/docs/examples/learn/29-voice/listen.caps/)
- [learn/29-voice/model.fails](https://tin.ad/docs/examples/learn/29-voice/model.fails/)
- [learn/29-voice/session](https://tin.ad/docs/examples/learn/29-voice/session/)
- [learn/29-voice/task-1](https://tin.ad/docs/examples/learn/29-voice/task-1/)
- [learn/29-voice/task-1.solution](https://tin.ad/docs/examples/learn/29-voice/task-1.solution/)
- [learn/30-server/agent.serve](https://tin.ad/docs/examples/learn/30-server/agent.serve/)
- [learn/30-server/grants.fails](https://tin.ad/docs/examples/learn/30-server/grants.fails/)
- [learn/30-server/hello.serve](https://tin.ad/docs/examples/learn/30-server/hello.serve/)
- [learn/30-server/injection.fails](https://tin.ad/docs/examples/learn/30-server/injection.fails/)
- [learn/30-server/parsed.fails](https://tin.ad/docs/examples/learn/30-server/parsed.fails/)
- [learn/30-server/redirect.fails](https://tin.ad/docs/examples/learn/30-server/redirect.fails/)
- [learn/30-server/task-1.solution.serve](https://tin.ad/docs/examples/learn/30-server/task-1.solution.serve/)
- [learn/30-server/types.serve](https://tin.ad/docs/examples/learn/30-server/types.serve/)
- [learn/31-telemetry/spans](https://tin.ad/docs/examples/learn/31-telemetry/spans/)
- [learn/31-telemetry/task-1.solution](https://tin.ad/docs/examples/learn/31-telemetry/task-1.solution/)
- [learn/32-robots/arm](https://tin.ad/docs/examples/learn/32-robots/arm/)
- [learn/32-robots/bare.fails](https://tin.ad/docs/examples/learn/32-robots/bare.fails/)
- [learn/32-robots/task-1.solution](https://tin.ad/docs/examples/learn/32-robots/task-1.solution/)
- [learn/32-robots/typo.fails](https://tin.ad/docs/examples/learn/32-robots/typo.fails/)
- [learn/33-policies/forms](https://tin.ad/docs/examples/learn/33-policies/forms/)
- [learn/33-policies/tape](https://tin.ad/docs/examples/learn/33-policies/tape/)
- [learn/33-policies/task-1.solution](https://tin.ad/docs/examples/learn/33-policies/task-1.solution/)
- [learn/33-policies/wave](https://tin.ad/docs/examples/learn/33-policies/wave/)
- [learn/34-robot-safety/drive](https://tin.ad/docs/examples/learn/34-robot-safety/drive/)
- [learn/34-robot-safety/gate](https://tin.ad/docs/examples/learn/34-robot-safety/gate/)
- [learn/34-robot-safety/reply.fails](https://tin.ad/docs/examples/learn/34-robot-safety/reply.fails/)
- [learn/34-robot-safety/task-1.solution](https://tin.ad/docs/examples/learn/34-robot-safety/task-1.solution/)
- [mcp/client](https://tin.ad/docs/examples/mcp/client/) A Tin program using an MCP server's tools as typed functions.
- [mcp/units](https://tin.ad/docs/examples/mcp/units/) A Tin program as an MCP server: its tool fns become MCP tools, with schemas from the types.
- [modules/kinematics](https://tin.ad/docs/examples/modules/kinematics/) A second file: everything declared here is visible to the files that import it.
- [modules/main](https://tin.ad/docs/examples/modules/main/) A program in two files.
- [mujoco/wave](https://tin.ad/docs/examples/mujoco/wave/) The same wave as examples/robots/wave.tin, in real physics: one word picks the world.
- [namespaces/arm](https://tin.ad/docs/examples/namespaces/arm/) Imported with `import "./arm.tin" as arm`: everything here is arm.name to the importer.
- [namespaces/base](https://tin.ad/docs/examples/namespaces/base/) Imported with `import "./base.tin" as base`.
- [namespaces/main](https://tin.ad/docs/examples/namespaces/main/) Namespaced modules: `import "./file.tin" as name` puts the file's types, functions, constants and agents under `name.`, so two files may use the same names.
- [packages/app/main](https://tin.ad/docs/examples/packages/app/main/) A program that uses the geometry package from ../geometry (see tin.toml).
- [packages/geometry/lib](https://tin.ad/docs/examples/packages/geometry/lib/) geometry: small 2D helpers for robot arms.
- [packages/geometry/vec](https://tin.ad/docs/examples/packages/geometry/vec/) Vectors in the plane.
- [policies/walk](https://tin.ad/docs/examples/policies/walk/) A humanoid walking on a learned policy: the holosoma ONNX checkpoint on the Unitree G1, in MuJoCo.
- [py/stats](https://tin.ad/docs/examples/py/stats/) Calling Python from Tin: `import py "module"` names a module (a .py file next to this one, or anything installed), and each `extern fn` in the block is a function in it.
- [robots/pick](https://tin.ad/docs/examples/robots/pick/) Waypoints, then a chunked policy, then seeded noise on top: every run of this program is identical.
- [robots/wave](https://tin.ad/docs/examples/robots/wave/) Wave an SO-101 arm's shoulder for five seconds in the built-in kinematic world.
- [server/shop](https://tin.ad/docs/examples/server/shop/) A small shop backend: typed routes, an agent behind a route, a voice line, and request input that the compiler keeps away from outside code.
- [wasi/stats](https://tin.ad/docs/examples/wasi/stats/) A command-line tool with no JavaScript in it: build it for WASI, run it with wasmtime.

## Agents

- [01-tools](https://tin.ad/docs/examples/agents/01-tools/) Tools and agents are part of the language.
- [02-typed](https://tin.ad/docs/examples/agents/02-typed/) A typed call: the type you expect decides the shape of the reply.
- [03-team](https://tin.ad/docs/examples/agents/03-team/) Agents compose with everything else in the language.
- [04-approval](https://tin.ad/docs/examples/agents/04-approval/) `guarded tool fn` puts a human in the loop.
- [05-claude](https://tin.ad/docs/examples/agents/05-claude/) The same language features, with a real model. Replays a recorded tape.
- [06-chat](https://tin.ad/docs/examples/agents/06-chat/) An interactive chat with a tool, in thirty lines. Replays a recorded tape.
- [07-capabilities](https://tin.ad/docs/examples/agents/07-capabilities/) Capabilities are checked by the compiler, before anything runs.
- [08-fleet](https://tin.ad/docs/examples/agents/08-fleet/) A fleet: one planner, two workers, and a person who approves the risky part. Replays a recorded tape.
- [09-code](https://tin.ad/docs/examples/agents/09-code/) Code as action: the model answers by writing a program. Replays a recorded tape.
- [10-try](https://tin.ad/docs/examples/agents/10-try/) Handling a failed agent call.
- [11-timestamps](https://tin.ad/docs/examples/agents/11-timestamps/) 64-bit integers at the agent boundary.
- [12-resume](https://tin.ad/docs/examples/agents/12-resume/) Saving and restoring an agent.
- [13-voice](https://tin.ad/docs/examples/agents/13-voice/) Talking agents: a `voice agent` holds a live, two-way conversation with a speech-to-speech model.
- [14-call](https://tin.ad/docs/examples/agents/14-call/) A phone call with an agent: microphone in, speaker out, until the call ends.
- [hello-native](https://tin.ad/docs/examples/agents/hello-native/) A hello agent for `tin build --native` (npm run smoke:native runs it live on Amazon Bedrock). Replays a recorded tape.
