Home / Docs / Language guide

Modules and imports

Release v0.4.0

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

src/shop/prices.unauna
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.unauna
module shop.cart

import shop.prices (Item, total)

pub kind Cart
  items: List[Item]

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