a tool for shared writing and social publishing
1// Result type - a discriminated union for handling success/error cases
2export type Result<T, E> =
3 | { ok: true; value: T }
4 | { ok: false; error: E };
5
6// Constructors
7export const Ok = <T>(value: T): Result<T, never> => ({ ok: true, value });
8export const Err = <E>(error: E): Result<never, E> => ({ ok: false, error });