---
title: "Modules and imports"
url: https://una-lang.org/en/docs/language/modules/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/docs/guide/syntax-reference.md
---

# Modules and imports

A package with two modules, one importing from the other:

`src/shop/prices.una`

```una
module shop.prices

pub kind Price = Int in 0..1_000_000

pub kind Item
  name: Text
  price: Price

--- Private: other modules cannot import it (U1004).
cents(item: Item) -> Int = item.price

pub total(items: List[Item]) -> Int = items.map(each: fn(i) -> cents(i)).sum()
```

`src/shop/cart.una`

```una
module shop.cart

import shop.prices (Item, total)

pub kind Cart
  items: List[Item]

pub cart_total(cart: Cart) -> Int = total(cart.items)
```

- **Module path and file path must match** (U1008): module `shop.cart` lives in `src/shop/cart.una`.
- **`trusted module`** marks a module allowed to declare policies (§8.5). It must also be listed in `una.toml`.
- **Imports list names explicitly.** Kinds, functions, capabilities, handlers, policies and predicates are all imported the same way. `std.testing` is the only standard module (§12).
- **The prelude is imported automatically** (§12).
- **Visibility:** declarations are private unless marked `pub`. Using a private declaration from another module is U1004. Import cycles are U1003.
- **Order:** declarations can appear in any order within a module.

---
