<!-- Package docs · Tin · https://tin.ad/docs/ref/api/ · generated from the built page -->

[Reference](https://tin.ad/docs/ref/)

-  [The language](https://tin.ad/docs/ref/language/)
-  [Agents and tools](https://tin.ad/docs/ref/agents/)
-  [Model providers](https://tin.ad/docs/ref/providers/)
-  [The Anthropic API](https://tin.ad/docs/ref/anthropic/)
-  [Talking agents](https://tin.ad/docs/ref/bidi/)
-  [Standard library](https://tin.ad/docs/ref/stdlib/)
-  [Glossary](https://tin.ad/docs/ref/glossary/)
-  [Package docs](https://tin.ad/docs/ref/api/)
- [tin doc](#tin-doc)
- [examples/packages/geometry/lib.tin](#lib)
- [examples/packages/geometry/vec.tin](#vec)
-  [Telemetry](https://tin.ad/docs/ref/telemetry/)
-  [Robots](https://tin.ad/docs/ref/robot/)
-  [Servers](https://tin.ad/docs/ref/server/)
-  [Deploying](https://tin.ad/docs/ref/deploy/)
-  [tin.ad](https://tin.ad/docs/ref/cloud/)
-  [The tin command](https://tin.ad/docs/ref/cli/)
-  [How it works](https://tin.ad/docs/ref/internals/)

**Reference · Package docs

- [The language](https://tin.ad/docs/ref/language/)
- [Agents and tools](https://tin.ad/docs/ref/agents/)
- [Model providers](https://tin.ad/docs/ref/providers/)
- [The Anthropic API](https://tin.ad/docs/ref/anthropic/)
- [Talking agents](https://tin.ad/docs/ref/bidi/)
- [Standard library](https://tin.ad/docs/ref/stdlib/)
- [Glossary](https://tin.ad/docs/ref/glossary/)
- [Package docs](https://tin.ad/docs/ref/api/)
- [Telemetry](https://tin.ad/docs/ref/telemetry/)
- [Robots](https://tin.ad/docs/ref/robot/)
- [Servers](https://tin.ad/docs/ref/server/)
- [Deploying](https://tin.ad/docs/ref/deploy/)
- [tin.ad](https://tin.ad/docs/ref/cloud/)
- [The tin command](https://tin.ad/docs/ref/cli/)
- [How it works](https://tin.ad/docs/ref/internals/)

On this page

- [tin doc](#tin-doc)
- [examples/packages/geometry/lib.tin](#lib)
- [examples/packages/geometry/vec.tin](#vec)

# Package docs

API documentation generated by tin doc from a package's source and its /// comments. Below: the example package examples/packages/geometry.

## tin doc

A `///` comment documents the declaration under it: a function, tool, type, field,
trait, trait method, agent or constant. A file's first `//` comment block introduces the
file. `tin doc` lists every public declaration with its signature as the compiler reads it,
with methods under their type. Names starting with `__` are left out.

```tin
/// A 2D vector, in meters.
type Vec = {
  /// Across, positive to the right.
  x: float,
  y: float,
}

/// The length of `v`: `Vec { x: 3.0, y: 4.0 }.len()` is 5.0.
fn Vec.len(v: Vec): float => sqrt(v.x * v.x + v.y * v.y)
```

<!-- output -->
```text
$ cd examples/packages/geometry && tin doc
doc/index.html  2 files, 5 items
```

 In a folder with a `tin.toml`, `tin doc` documents every `.tin` file next to it
and in `src/`, except `main.tin`. Name files to document only those. It writes one page
per file and an `index.html` into `doc/` (`-o` for another folder), each a
single HTML file with no scripts. `--json` prints the same content as data. Comments may use
`` `code` ``, `**bold**`, `[links](https://…)`, paragraphs and `- ` lists.
The editor's hover shows the same comments (see [tin lsp](https://tin.ad/docs/ref/cli/#lsp)).

## `examples/packages/geometry/lib.tin`

geometry: small 2D helpers for robot arms. Import it with `import "geometry"`, or one file with `import "geometry/vec"`.

- [VERSION](#const.VERSION) const
- [toRadians](#fn.toRadians) fn

### const [VERSION](#const.VERSION)

```tin
let VERSION = "0.1.0"
```

### fn [toRadians](#fn.toRadians)

```tin
fn toRadians(deg: float): float
```

Degrees to radians: `toRadians(180.0)` is π.

## `examples/packages/geometry/vec.tin`

Vectors in the plane.

- [Vec](#type.Vec) type
- [Reach](#type.Reach) type
- [reach](#fn.reach) fn

### type [Vec](#type.Vec)

```tin
type Vec = { x: float, y: float }
```

A 2D vector, in meters.

#### field [x](#Vec.x)

```tin
x: float
```

Across, positive to the right.

#### field [y](#Vec.y)

```tin
y: float
```

Up, positive away from the floor.

#### method [len](#Vec.len)

```tin
fn Vec.len(v: Vec): float
```

The length of `v`: `Vec { x: 3.0, y: 4.0 }.len()` is 5.0.

#### method [plus](#Vec.plus)

```tin
fn Vec.plus(v: Vec, w: Vec): Vec
```

`v` and `w` added component by component.

### type [Reach](#type.Reach)

```tin
type Reach = Inside | Edge | Outside(float)
```

How a point relates to an arm's reach.

#### variant [Inside](#Reach.Inside)

```tin
Inside
```

#### variant [Edge](#Reach.Edge)

```tin
Edge
```

#### variant [Outside](#Reach.Outside)

```tin
Outside(float)
```

### fn [reach](#fn.reach)

```tin
fn reach(p: Vec, limit: float): Reach
```

Where `p` is for an arm that reaches `limit` meters. **Edge** means within 1 cm.
