context demo.agt

type Counter = opaque Int where NonNegative
type OrderError = | OutOfStock

agent Box {
  key id: Counter

  store placed: Cell[Bool]

  on call place(amount: Int) -> Effect[Result[(), OrderError]] {
    if amount > 0 {
      placed := true
      Ok(())
    } else {
      Err(OutOfStock)
    }
  }
}
