export function todo(msg?: string): T { class NotImplemented extends Error {} throw new NotImplemented(msg); } export function exhausted(_: never) { class Unexhausted extends Error {} throw new Unexhausted(); } export type Res = Ok | Err; export type Ok = { ok: true; val: V }; export type Err = { ok: false; val: E }; export const Ok = (val: V): Ok => ({ ok: true, val }); export const Err = (val: E): Err => ({ ok: false, val }); export const Res = { Ok, Err } as const; export type ControlFlow< R = undefined, V = undefined, > = Break | Continue; export type Break = { break: true; val: R }; export type Continue = { break: false; val: V }; export const ControlFlow = { Break: (val: R): Break => ({ break: true, val }), Continue: (val: V): Continue => ({ break: false, val }), } as const; export const range = (length: number) => (new Array(length).fill(0));