A common pattern is a result that can be OK or an error. Aliasing each variant and the union keeps function signatures tight and readable. Narrow by the discriminant to decide which fields are available.
type Ok = { ok: true; value: string }type Fail = { ok: false; error: string }type Result = Ok | Fail.summarize(r: Result): string:"OK: <value>" when ok: true"ERROR: <error>" when ok: false.