A tour of Tin
Eight short chapters for people who already program. Every code block is a real file from examples/,
and every output is what the test suite checks.
Coming from Python or TypeScript? Read the side-by-side. Want it slowly, with tasks? Learn Tin.
- 1Hello, TinA program is a file with a
main. Strings interpolate, and everything is an expression. - 2Structs and sum typesData is described with
type. A sum type lists every shape a value can take, andmatchmust handle all of them. Every value is copied, never shared. - 3No null, no exceptionsA value that may be missing is an
Option. An operation that may fail returns aResult.?passes the failure up. - 4Functions, pipelines and closures
x |> f(y)meansf(x, y), and so doesx.f(y). Use whichever reads better. - 5GenericsGeneric code is specialised at compile time.
Stack<int>andStack<string>become separate WebAssembly functions. - 6Concurrency without coloursThere is no
asynckeyword. Any function can suspend, and callers don’t have to know.spawnstarts a task,awaitwaits for it, and no task outlives its parent. - 7Tools and agentsA
tool fnis a function the compiler also describes to a model. Anagentis called like a function. - 8Guarded tools and teamsPut a human in the loop with one word. Compose agents with the tools you already know: sub-agents,
spawnand|>.