Tin

Examples · learn/19-capabilities · 242 of 339

task-2.solution.caps

examples/learn/19-capabilities/task-2.solution.caps.tintin run examples/learn/19-capabilities/task-2.solution.caps.tin
/// Look up a price, in cents.
tool fn price(item: string): int => 300

/// Charge a card. A person approves every charge.
guarded tool fn charge(card: string, cents: int): string => "charged {cents}"

/// Takes orders. It can no longer charge on its own: the Cashier does that.
agent Till { model: "mock", tools: [price, Cashier] }

/// Charges cards, after a person approves.
agent Cashier { model: "mock", tools: [charge] }

fn main() {}