Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View julien1619's full-sized avatar

Julien Blatecky julien1619

View GitHub Profile
@s-panferov
s-panferov / result.ts
Created November 19, 2014 14:11
Result type in TypeScript
interface Result<T, E> {
map<U>(fn: (a: T) => U): Result<U, E>;
mapErr<U>(fn: (a: E) => U): Result<T, U>;
isOk(): boolean;
isErr(): boolean;
ok(): Option<T>;
err(): Option<E>;
and<U>(res: Result<U,E>): Result<U,E>;
andThen<U>(op: (T) => Result<U,E>): Result<U,E>;