context demo.svc
exports opaque { AuthId }
exports transparent { PaymentError }

type AuthId = opaque String
type PaymentError = | Declined | InsufficientFunds

service authorise {
  on call(amount: Int) -> Effect[Result[AuthId, PaymentError]] {
    if amount == 0 {
      Err(Declined)
    } else if amount > 1000000 {
      Err(InsufficientFunds)
    } else {
      Ok(AuthId.unsafe("AUTH-DEFAULT"))
    }
  }
}
