Tin

Examples · learn/17-typed-replies · 224 of 339

order

examples/learn/17-typed-replies/order.tintin run examples/learn/17-typed-replies/order.tin
type Size = | Small | Medium | Large

type Order = {
  /// What the customer wants to drink
  drink: string
  size: Size
  /// How many cups
  quantity: int
  /// Extra requests, if any
  notes: Option<string>
}

agent Clerk { model: "mock", system: "You take coffee orders." }

fn main() {
  let order: Order = Clerk("Two cups please: 2 of the 'oat latte', Large")
  print(order)
  print("{order.quantity} x {order.drink}")
  print(match order.size {
    Large => "use the big cups"
    _ => "regular cups"
  })
}