import { Monad } from '../control/monad'; import { Alt } from '../control/alt'; import { Plus } from '../control/plus'; import { Alternative } from '../control/alternative'; import { Extend } from '../control/extend'; import { Eq } from './eq'; /** * Maybe monad represents an optional or nullable value. */ export declare abstract class Maybe implements Monad, Alt, Plus, Alternative, Extend, Eq> { static of(value: A): Maybe; static just(value: A): Maybe; static nothing(): Maybe; /** * fromNullable constructs a Maybe from a value that may be null. */ static fromNullable: (a: A_1 | undefined | null) => Maybe; /** * fromArray checks an array to see if it's empty * * Returns [[Nothing]] if it is, [[Just]] otherwise. */ static fromArray: (a: A_1[]) => Maybe; /** * fromObject uses Object.keys to turn see if an object * has any own properties. */ static fromObject: (o: A_1) => Maybe; /** * fromString constructs Nothing if the string is empty or Just otherwise. */ static fromString: (s: string) => Maybe; /** * fromBoolean constructs Nothing if b is false, Just otherwise */ static fromBoolean: (b: boolean) => Maybe; /** * fromNumber constructs Nothing if n is 0 Just otherwise. */ static fromNumber: (n: number) => Maybe; abstract of(a: A): Maybe; abstract map(_: (a: A) => B): Maybe; abstract ap(_: Maybe<(a: A) => B>): Maybe; abstract chain(_: (a: A) => Maybe): Maybe; abstract alt(a: Maybe): Maybe; abstract eq(e: Maybe): boolean; abstract extend(_: (ex: Maybe) => B): Maybe; /** * orJust is like applying map to the Nothing side. */ abstract orJust(_f: () => B): Maybe; /** * orElse allows for an alternative Maybe value to * be provided when Nothing but using a function. */ abstract orElse(f: () => Maybe): Maybe; /** * isNothing tests whether the Maybe is a Nothing. */ abstract isNothing(): boolean; /** * isJust tests whether the Maybe is a Just. */ abstract isJust(): boolean; /** * get the value from a Maybe. */ abstract get(): A; empty(): Maybe; } /** * Nothing represents the absence of a usable value. */ export declare class Nothing extends Maybe { map(_: (a: A) => B): Maybe; ap(_: Maybe<(a: A) => B>): Maybe; of(a: A): Maybe; chain(_: (a: A) => Maybe): Maybe; alt(a: Maybe): Maybe; extend(_: (ex: Maybe) => B): Maybe; eq(m: Maybe): m is Nothing; orJust(f: () => B): Maybe; orElse(f: () => Maybe): Maybe; isNothing(): boolean; isJust(): boolean; get(): A; } /** * Just represents the presence of a usable value. */ export declare class Just extends Maybe { value: A; constructor(value: A); map(f: (a: A) => B): Maybe; ap(mb: Maybe<(a: A) => B>): Maybe; of(a: A): Maybe; chain(f: (a: A) => Maybe): Maybe; alt(_: Maybe): Maybe; extend(f: (ex: Maybe) => B): Maybe; eq(m: Maybe): boolean; orJust(_: (a: A) => B): Maybe; orElse(_: (a: A) => B): Maybe; isNothing(): boolean; isJust(): boolean; get(): A; } export declare const nothing: typeof Maybe.nothing; export declare const just: typeof Maybe.just; export declare const fromNullable: (a: A | undefined | null) => Maybe; export declare const fromArray: (a: A[]) => Maybe; export declare const fromObject: (o: A) => Maybe; export declare const fromString: (s: string) => Maybe; export declare const fromBoolean: (b: boolean) => Maybe; export declare const fromNumber: (n: number) => Maybe; export declare const fromNaN: (n: number) => Maybe;