/** * A successful value */ export declare type Ok = { _tag: 'ok'; value: R; }; /** * A failed value */ export declare type Err = { _tag: 'error'; error: L; }; /** * A safe result type: imagine a language with no exceptions — the way to handle * errors would be to use something like a tagged union type. * * Why would we want that? I want to explicitly handle exceptions in this library * and having this construct really helps. It's also pretty easy to implement. */ export declare type Result = Err | Ok; export declare function ok(value: O): Ok; export declare function err(error: E): Err; /** * Checks whether a value is an `Ok`. * Handy with TypeScript guards */ export declare function isOk(result: Result): result is Ok; /** * Checks whether a value is an `Err`. * Handy with TypeScript guards */ export declare function isErr(either: Result): either is Err; /** * Convert a `Promise` into a `Promise>`, * therefore catching the errors and being able to handle them explicitly */ export declare function safeAsync(promise: Promise): Promise>;