export nominal OrderId = string export nominal Cents = int export type Count = int export type Bool = boolean export type Text = string export type StateName = "pending" | "paid" | "shipped" | "cancelled" export type Receipt = { number: Text } export type Tracking = { code: Text } export type Reason = { note: Text } export nominal Pending = { id: OrderId, total: Cents } export nominal Paid = { id: OrderId, total: Cents, receipt: Receipt } export nominal Shipped = { id: OrderId, receipt: Receipt, tracking: Tracking } export nominal Cancelled = { id: OrderId, reason: Reason } export type Order = Pending | Paid | Shipped | Cancelled export error InvalidTransition = { id: OrderId, state: StateName } export nominal Fixed = { amount: Cents } export nominal Times = { factor: Count } export nominal Capped = { rule: Rule, cap: Cents } export nominal Sum = { parts: Rule[] } export type Rule = Fixed | Times | Capped | Sum export type OrderInput = { id: Text, total: Count }