export declare type MaybeMapping = (val: A) => B; export declare type MaybePredicate = (val: T) => boolean; export declare abstract class Maybe { static fromNullable(val: T | undefined | null): Maybe; static nothing(): Nothing; static just(val: T): Just; /** * Returns a new Maybe containing the values, as an array, of the given Maybes. If any of the given * Maybes is a Nothing a Nothing is returned. */ static all(a: Maybe, b: Maybe): Maybe<[A, B]>; static all(a: Maybe, b: Maybe, c: Maybe): Maybe<[A, B, C]>; static all(a: Maybe, b: Maybe, c: Maybe, d: Maybe): Maybe<[A, B, C, D]>; abstract join(this: Maybe>): Maybe; abstract fork(justFn: (val: T) => B, _: () => B): B; abstract map(mapping: MaybeMapping): Maybe; abstract chain(mapping: (val: T) => Maybe): Maybe; abstract filter(predicate: MaybePredicate): Maybe; abstract get(): T; abstract getOrElse(defaultValue: T): T; abstract isJust(): boolean; abstract isNothing(): boolean; } export declare class Just extends Maybe { static create(val: B): Just; private value; constructor(val: T); toString(): string; /** * join :: Maybe (Maybe a) -> Maybe a * * Takes a nested Maybe and removes one level of nesting. * * @name join * @method * @memberof Maybe# * @returns {Maybe} */ join(this: Maybe>): Maybe; /** * @name fork * @method * @memberof Maybe# * @param {Function} justFn Function to call with value of Just * @param {Function} nothingFn Function to call with value of Nothing * @returns {*} The return value of the matching function */ fork(justFn: (val: T) => B, _: () => B): B; /** * map :: Maybe a -> (a -> b) -> Maybe b * * Transforms the value of a Maybe with the given function. * * @name map * @method * @memberof Maybe# * @param {Function} mapping Function used to map value of Maybe * @returns {Maybe} */ map(mapping: MaybeMapping): Maybe; /** * chain :: Maybe a -> (a -> Maybe b) -> Maybe b * * Takes the value of a Maybe and gives it to a function that returns a new Maybe. * * @name chain * @method * @memberof Maybe# * @param {Function} mapping Function used to create new Maybe * @returns {Maybe} */ chain(mapping: (val: T) => Maybe): Maybe; /** * filter :: Maybe a -> (a -> Boolean) -> Maybe a * * Turns a Just into a Nothing if the predicate returns false * * @name filter * @method * @memberof Maybe# * @param {Function} predicate Function used to test value * @returns {Maybe} */ filter(predicate: MaybePredicate): Maybe; /** * get :: Maybe a -> a * * Extract the value from a Maybe * * @name get * @method * @memberof Maybe# * @returns {*} */ get(): T; /** * getOrElse :: Maybe a -> a -> a * * @name getOrElse * @method * @memberof Maybe# * @returns {*} */ getOrElse(_: T): T; /** * isNothing :: Maybe a -> Boolean * * @name isNothing * @method * @memberof Maybe# * @returns {Boolean} */ isNothing(): boolean; /** * isJust :: Maybe a -> Boolean * * @name isJust * @method * @memberof Maybe# * @returns {Boolean} */ isJust(): boolean; } export declare class Nothing extends Maybe { static create(): Nothing; toString(): string; fork(_: (val: T) => B, nothingFn: () => B): B; join(this: Maybe>): Maybe; map(_: MaybeMapping): Maybe; filter(_: MaybePredicate): Maybe; chain(_: (val: T) => Maybe): Maybe; get(): T; getOrElse(val: T): T; isJust(): boolean; isNothing(): boolean; }