import { Monad } from '../monad/Monad'; /** * left wraps a value on the left side. */ export declare const left: (a: A) => Left; /** * right wraps a value on the right side. */ export declare const right: (b: B) => Right; /** * fromBoolean constructs an Either using a boolean value. */ export declare const fromBoolean: (b: boolean) => Either; /** * Either monad implementation */ export declare abstract class Either implements Monad { static left: (a: A) => Left; static right: (b: B) => Right; static fromBoolean: (b: boolean) => Either; of(v: R): Either; abstract map(f: (r: R) => B): Either; abstract mapLeft(f: (l: L) => B): Either; abstract bimap(f: (l: L) => LL, g: (r: R) => RR): Either; /** * chain */ abstract chain(f: (r: R) => Either): Either; /** * orElse returns the result of f if the Either is left. */ abstract orElse(f: (l: L) => Either): Either; /** * orRight is like orElse except it just expects the value */ abstract orRight(f: (l: L) => R): Either; /** * ap */ abstract ap(e: Either B>): Either; /** * takeLeft extracts the left value of an Either, throwing an error if the Either is right. */ abstract takeLeft(): L; /** * takeRight is the opposite of left * @summary Either → B|Error */ abstract takeRight(): R; /** * cata */ abstract cata(f: (l: L) => B, g: (r: R) => B): B; } export declare class Left extends Either { l: L; constructor(l: L); map(_: (r: R) => B): Either; mapLeft(f: (l: L) => B): Either; bimap(f: (l: L) => LL, _: (r: R) => RR): Either; chain(_: (r: R) => Either): Either; orElse(f: (l: L) => Either): Either; orRight(f: (l: L) => R): Either; ap(_: Either B>): Either; takeLeft(): L; takeRight(): R; cata(f: (l: L) => B, _: (r: R) => B): B; } export declare class Right extends Either { r: R; constructor(r: R); map(f: (r: R) => B): Either; mapLeft(_: (l: L) => B): Either; bimap(_: (l: L) => LL, g: (r: R) => RR): Either; chain(f: (r: R) => Either): Either; /** * orElse returns the result of f if the Either is left. */ orElse(_: (l: L) => Either): Either; orRight(_: (l: L) => R): Either; /** * ap */ ap(e: Either B>): Either; /** * takeLeft extracts the left value of an Either, throwing an error if the Either is right. */ takeLeft(): L; takeRight(): R; /** * cata */ cata(_: (l: L) => B, g: (r: R) => B): B; }