/** * Minimal implementation of a Maybe monad * loosely based on https://github.com/patrickmichalina/typescript-monads/blob/master/src/maybe/maybe.ts */ export declare class Maybe { private _value; private _isNone; constructor(value?: T | null); static of(value?: T): Maybe; static ofFalsy(value?: T): Maybe>; get isSome(): boolean; valueOr(defaultValue: U): T | U; map(fn: (value: NonNullable) => U): Maybe; mapOr(defaultValue: U, fn: (value: NonNullable) => U): U; mapOrUndefined(fn: (value: NonNullable) => U): U | undefined; mapOrNull(fn: (value: NonNullable) => U): U | null; } /** * Minimal implementation of an Either monad */ export declare class Either { private _value; private _isLeft; constructor(isLeft: boolean, value: L | R); static left(value: L): Either; static right(value: R): Either; isLeft(): boolean; isRight(): boolean; left(): L | undefined; right(): R | undefined; map(fn: (value: R) => R2): Either; mapLeft(fn: (value: L) => L2): Either; flatMap(fn: (value: R) => Either): Either; fold(onLeft: (value: L) => U, onRight: (value: R) => U): U; value(): L | R; } /** * Minimal implementation of a Result monad that wraps an Either */ export declare class Result extends Either { constructor(either: Either); static ok(value: T): Result; static error(value: E): Result; static fromEither(either: Either): Result; ok(): T | undefined; error(): E | undefined; mapError(fn: (value: E) => E2): Result; flatMap(fn: (value: T) => Either): Result; }