Home / Docs / Configure a package

[run] entry

Release v0.4.0Edition 0.1 and laterU3012U7002

What it does

entry names the module whose main function una run and una build start: the first code of the program to run. main is pub main() -> Unit, and it receives host capabilities, the authority to use the console, files, the clock and the like that the runtime provides, through its uses clauses.

Learn more: The host's capabilities and grants.

una.tomltoml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[run]
entry = "shop"
grants = ["console"]
src/shop.unauna
module shop

pub main() -> Unit
  uses @console: Console[print]
=
  @console.print("the shop is open")

Forms

toml
[run]
entry = "<module path>"

The path of a module of the package, as its module line writes it: shop for src/shop.una, shop.orders for src/shop/orders.una.

Examples

An entry that names no module of the package is rejected:

una.tomltoml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[run]
entry = "missing"
grants = ["console"]
src/shop.unauna
-- fails with U7002
module shop

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

Edge cases

main takes host capabilities only. No grant can provide a capability that is not a host capability, so una check reports it:

una.tomltoml
[package]
name = "shop"
version = "0.1.0"
edition = "0.2"

[run]
entry = "shop"
grants = ["console"]
src/shop.unauna
-- fails with U3012
module shop

pub capability Log
  op write(line: Text) -> Unit

pub main() -> Unit
  uses @log: Log[write]
=
  @log.write("order 42 shipped")

Further rules:

Diagnostics

Edition

entry is the same in editions 0.1 and 0.2. From edition 0.4 it is written in the run section of ita.una, as entry <module> (see ita.una).

Normative source