Home / Docs / Una for agents

Una, compact

Release v0.4.0Edition 0.2

Edition 0.2 only, not 0.3 or 0.4. Full guide: una-for-agents.md.

Loop. una fmt ., una fix . (safe mechanical edits), una --json check .; read code and repairs, una explain <code>; then una --json test ..

Package. una.toml ([package] name, version, edition = "0.2"; [run] entry, grants; [trusted] modules), verification.lock (pins Z3), src/<module>.una.

Syntax.

Functions. Clauses in order requires, ensures, uses, fails, then = and the body below. No clauses: f(x: Int) -> Int = x * 2. kind P = A(x: Int) | B is a sum; indented name: Type lines make a record. when v has arms is A(x) -> ... and else -> ....

Failures. Declare fails E (one sum kind); fail with fail V(...). Handle a failing call on the lines below it with if error pass, if error fail V, if error use v, if none fail V or if none use v; attempt f(x) gives a Result. An effect or fallible call is a whole statement or let (U3013).

Capabilities. There is no ambient authority.

Labels. public < internal < confidential < secret < restricted.

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

[trusted]
modules = ["release"]
src/release.unauna
trusted module release

pub policy shown
  from internal Text
  to public Text
  via copy
  purpose "show a name"
  owner ops

copy(t: internal Text) -> public Text = t

Contracts.

Loops.

una
module tally

add(edit counts: Map[Text, Int], key: Text) -> Unit
  ensures counts.has(key: key)
=
  let n = counts.get(key: key)
    if none use 0
  edit counts.set(key: key, value: n + 1)

pub tally(keys: List[Text]) -> Map[Text, Int]
=
  let edit counts: Map[Text, Int] = empty_map()
  for key in keys
    add(edit counts, key)
  counts

Library.

Examples. given @x = handler(...) lines (no host capabilities), one do expr, expect lines over result, fails V or performed @x.op.