---
title: "[labels] categories"
url: https://una-lang.org/en/docs/configure/labels/categories/
release: v0.4.0
edition: "0.1 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/guide/configure/labels/categories.md
---

# [labels] categories

## What it does

A label marks how sensitive a value is, so the checker can keep it from reaching a place that must not see it, such as the console. A label is a level, one of `public`, `internal`, `confidential`, `secret` and `restricted` from least to most sensitive, and a set of categories, names that say what kind of data it is, such as `PII` for personal data. `categories` declares the categories the package's code may use, as in `secret[PII]`. A value flows only to labels at least as high in both.

Learn more: [Categories](https://una-lang.org/en/learn/information-flow/categories/) and [Labels and how they follow data](https://una-lang.org/en/learn/information-flow/labels-and-how-they-follow-data/).

`una.toml`

```toml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[labels]
categories = ["PII", "Location"]
```

`src/shop.una`

```una
module shop

pub tagged(birth_year: secret[PII] Int) -> secret[PII] Int = birth_year

pub wider(birth_year: secret[PII] Int) -> restricted[PII, Location] Int = birth_year
```

## Forms

```text
[labels]
categories = ["<UpperCamelCase name>", ...]
```

An array of category names, each in UpperCamelCase (words run together, each starting with a capital letter, as `PII` or `ShippingAddress`) and unique. Without the table, a package declares no categories.

## Examples

A label may name only declared categories:

`una.toml`

```toml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"
```

`src/shop.una`

```una
-- fails with U4007
module shop

pub tagged(birth_year: secret[PII] Int) -> secret[PII] Int = birth_year
```

## Edge cases

**Names are UpperCamelCase**:

`una.toml`

```toml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[labels]
categories = ["pii"]
```

`src/shop.una`

```una
-- fails with U1005
module shop

pub price(cents: Int) -> Int = cents
```

**Each name once**:

`una.toml`

```toml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[labels]
categories = ["PII", "PII"]
```

`src/shop.una`

```una
-- fails with U1002
module shop

pub price(cents: Int) -> Int = cents
```

**Each name is a string**:

`una.toml`

```toml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[labels]
categories = [1]
```

`src/shop.una`

```una
-- fails with U7002
module shop

pub price(cents: Int) -> Int = cents
```

Further rules:

- **Order.** A label is below another when its level is not higher and its categories are a subset. See [labels](https://una-lang.org/en/docs/language/information-flow/labels/).

## Diagnostics

- [U1002](https://una-lang.org/en/docs/errors/U1002/): a category listed twice.
- [U1005](https://una-lang.org/en/docs/errors/U1005/): a category name that is not UpperCamelCase.
- [U4007](https://una-lang.org/en/docs/errors/U4007/): a label that names an undeclared category.
- [U7002](https://una-lang.org/en/docs/errors/U7002/): a `categories` that is not an array of strings.

## Edition

Categories are the same in editions `0.1` and `0.2`. From edition `0.4` they are written in the `labels` section of `ita.una`, one category per line (see [`ita.una`](https://una-lang.org/en/docs/configure/ita/manifest/)).

## Normative source

- `spec/13 §7`: `[labels]`.
- `spec/07 §2`: labels and categories.
