10 lines
289 B
TypeScript
10 lines
289 B
TypeScript
|
|
export type Result<T, E> =
|
|
| { tag: "ok", value: T }
|
|
| { tag: "error", error: E }
|
|
|
|
export namespace Result {
|
|
export function ok<T, E>(value: T): Result<T, E> { return { tag: "ok", value } }
|
|
export function error<T, E>(error: E): Result<T, E> { return { tag: "error", error } }
|
|
}
|
|
|