# Typed values

Source: https://libtmux.org/en/haskell/latest/guides/typed-values/

> Typed values: libtmux-haskell documentation.

[Run the complete example](https://github.com/libtmux/libtmux-haskell/blob/581f0ee45016ffb2283366bb1edc1658df26c5ed/examples/typed-values/Main.hs) from a checkout:

```console
$ cabal run --verbose=0 typed-values
```

Program output:

<!-- example-output: typed-values -->
```text
("3.3a","@17",120)
```

The program parses supplied text and constructs values. Its only [`IO`](<https://hackage-content.haskell.org/package/base-4.22.0.0/docs/System-IO.html#t:IO>) prints
the result; it neither inspects an installed tmux binary nor contacts a server.

## IDs and indices describe different things

[`SessionId`](https://libtmux.org/en/haskell/latest/reference/libtmux-id/), [`WindowId`](https://libtmux.org/en/haskell/latest/reference/libtmux-id/) and [`PaneId`](https://libtmux.org/en/haskell/latest/reference/libtmux-id/) are distinct types. Their parsers require
the corresponding `$`, `@` or `%` prefix, canonical decimal spelling and the
native unsigned 32-bit range. Leading zeroes and whitespace are rejected.
Use the rendering functions when producing external target text.

An ID alone carries no endpoint or server lifetime. Parsing `@17` does not
prove that a window exists. The ID API does not yet provide generation-bound
references for external operations.

[`WindowIndex`](https://libtmux.org/en/haskell/latest/reference/libtmux-value/) identifies a window link's position within a session.
[`PaneIndex`](https://libtmux.org/en/haskell/latest/reference/libtmux-value/) identifies a pane's position within its window. Neither is an
entity ID. A physical window may have several links, including multiple
indices in the same session.

## Validate values where they enter the program

Constructors return [`Either`](<https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Data-Either.html#t:Either>): dimensions must be positive; indices must be
nonnegative. Their numeric accessors return [`Integer`](<https://hackage-content.haskell.org/package/base-4.22.0.0/docs/Prelude.html#t:Integer>), so reading a value
does not narrow it to a machine-sized integer.

[`mkDimension`](https://libtmux.org/en/haskell/latest/reference/libtmux-value/) checks the mathematical domain. A particular tmux command can
impose a smaller numeric range; successful construction does not establish
that command's capability or maximum.

## Release admission has a limited meaning

[`parseVersion`](https://libtmux.org/en/haskell/latest/reference/libtmux-version/) accepts stable releases and the output format of `tmux -V`,
including one final LF. Development versions and trailing data are rejected.
[`requireSupported`](https://libtmux.org/en/haskell/latest/reference/libtmux-version/) admits the inclusive range from
tmux 3.3a through 3.8. Intermediate releases are supported; CI tests the endpoints.

These functions validate the supplied release identity. They do not inspect
the host or qualify all features of that release. See
[implementation status](https://libtmux.org/en/haskell/latest/guides/status/) for the boundary between the exposed
package and the transport work.

The [API guide](https://libtmux.org/en/haskell/latest/guides/api-documentation/) links the public modules and their error types.
