import {BinaryCurriedFn, Opaque, PlainObjectOf, TernaryCurriedFn} from './common'; import {Either} from './either'; export type Just = Opaque<"Just", T>; export type Nothing = Opaque<"Nothing", void>; export type Maybe = Nothing | Just; type Applicative = Promise|Either|PlainObjectOf; /** * creates a Just of the value */ export function just(x: T): Just; /** * alias for just */ export function of(x: T): Just; /** * Creates a Nothing */ export function nothing(): Nothing; /** * returns `true` if the Maybe is a Just */ export function isJust(mx: Maybe): boolean; export function isNothing(mx: Maybe): boolean; export function join(mx: Maybe>): Maybe; /** @deprecated Use FL compliant utility function e.g. R.equals */ export function equals(ma: Maybe, mb: Maybe): boolean; /** @deprecated Use FL compliant utility function e.g. R.equals */ export function equals(ma: Maybe) : (mb: Maybe) => boolean; export function fromNilable(x: (T|undefined|null)): Maybe; export function fromPredicate(pred: (x: T) => boolean, x: T): Maybe; export function fromPredicate(pred: (x: T) => boolean): (x: T) => Maybe; export function fromContentHolding(x: T): Maybe; export function getOrElse(acc: T, ma: Maybe) : T; export function getOrElse(acc: T) : (ma: Maybe) => T; /** @deprecated Use FL compliant utility function e.g. R.map */ export function map(fn: (x: T) => U, mx: Maybe): Maybe; /** @deprecated Use FL compliant utility function e.g. R.map */ export function map(fn: (x: T) => U) : (mx: Maybe) => Maybe; /** @deprecated Use FL compliant utility function e.g. R.pluck */ export function pluck(propertyName: string, mKv: Maybe>): Maybe; export function pluck(propertyName: string): (mKv: Maybe>) => Maybe; export function pluck(index: number, mKv: Maybe<[T]>): Maybe; export function pluck(index: number): (mKv: Maybe<[T]>) => Maybe; /** @deprecated Use FL compliant utility function e.g. R.chain */ export function chain(factory: (x: T) => Maybe, p: Maybe) : Maybe; export function chain(factory: (x: T) => Maybe): (p: Maybe) => Maybe; export function sequence( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative, mfa: Maybe>): Applicative>; export function sequence( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative): (mfa: Maybe>) => Applicative>; export function traverse( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative, effect: (a: A) => Applicative, ma: Maybe): Applicative>; export function traverse( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative, effect: (a: A) => Applicative): (ma: Maybe) => Applicative>; export function traverse( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative): (effect: (a: A) => Applicative, ma: Maybe) => Applicative>; export function traverse( ofF: (a: A) => Applicative, mapF: (f: (a: A) => B, ma: Applicative) => Applicative): (effect: (a: A) => Applicative) => (ma: Maybe) => Applicative>; export function tap(fn: (x: T) => any, p: Maybe): Maybe; export function tap(fn: (x: T) => any): (p: Maybe) => Maybe; export function biTap(onNothing: () => any, onJust: (x: T) => any, p: Maybe): Maybe; export function biTap(onNothing: () => any, onJust: (x: T) => any): (p: Maybe) => Maybe; export function maybe(onNothing: () => S, onJust: (x: T) => U, mx: Maybe): S|U; export function maybe(onNothing: () => S): (onJust: (x: T) => U, mx: Maybe) => S|U; export function maybe(onNothing: () => S, onJust: (x: T) => U): (mx: Maybe) => S|U; export function maybe(onNothing: () => S): (onJust: (x: T) => U) => (mx: Maybe) => S|U; export function liftA2(fn: BinaryCurriedFn): (ps: Maybe, pt: Maybe) => Maybe; export function liftA2(fn: BinaryCurriedFn): (ps: Maybe) => (pt: Maybe) => Maybe; export function liftA3(fn: TernaryCurriedFn): (ps: Maybe, pt: Maybe, pu: Maybe) => Maybe; export function liftA3(fn: TernaryCurriedFn): (ps: Maybe) => (pt: Maybe) => (pu: Maybe) => Maybe; export function lift(fn: (...args: any[]) => T): (...mxs: [Maybe]) => Maybe; export function typeString(mx: Maybe): string;