import { Either, Maybe, Validation, IValidationAcc, ISuccessStatic, IFailStatic } from 'monet'; /** * Creates a Validation from a possibly falsy value. * @param err - the default value of the Fail * @param value - the potentially falsy value of the Success * @returns a Success if the value was truthy, a Fail otherwise * ```typescript * Validations.fromTruthy(new Error(), null); // -> Fail(Error) * Validations.fromTruthy(new Error(), 'test'); // -> Success('test') * ``` */ export declare function fromTruthy(err: E, value: T | null | undefined): Validation>; /** * Flat maps a Success to a new Validation. * @alias successFlatMap * @alias bind * @alias chain * @param fn - the mapper function * @returns the flat mapped Validation * ```typescript * pipe( * Validations.Success('test'), * Validations.flatMap(str => Validations.Fail(new Error(str))) // -> Fail(Error) * ); * ``` */ export declare const flatMap: (fn: (a: T) => Validation) => (val: Validation) => Validation; /** * Maps a Success using a mapper function. * @alias successMap * @param fn - the mapper function * @returns the mapped Success, or an unchanged Fail * ```typescript * pipe( * Validations.Success(2), * Validations.map(num => num * 3) // -> Success(6) * ); * ``` */ export declare const map: (fn: (a: T) => V) => (val: Validation) => Validation; /** * Performs a catamorphism on a Validation. * @param fail - the function to unwrap a Fail * @param success - the function to unwrap a Success * @returns the result of the catamorphism * ```typescript * pipe( * Validations.Fail('fail'), * Validations.cata( * str => str + '!', // -> 'fail!' * num => num.toString() * ) * ); * * pipe( * Validations.Success(5), * Validations.cata( * str => str + '!', * num => num.toString() // -> '5' * ) * ); * ``` */ export declare const cata: (fail: (a: E) => V, success: (b: T) => V) => (val: Validation) => V; /** * Maps both sides of a Validation. * @alias mapBoth * @param fail - the mapper for a Fail * @param success - the mapper for a Success * @returns a mapped Validation * ```typescript * pipe( * Validations.Fail('fail'), * Validations.bimap( * str => str + '!', // -> Fail('fail!') * num => num.toString() * ) * ); * * pipe( * Validations.Success(5), * Validations.bimap( * str => str + '!', * num => num.toString() // -> Success('5') * ) * ); * ``` */ export declare const bimap: (fail: (a: E) => A, success: (b: T) => B) => (val: Validation) => Validation; /** * Maps a Fail using a mapper function. * @param fn - the mapper function * @returns a mapped Fail or an unchanged Success * ```typescript * pipe( * Validations.Fail(2), * Validations.failMap(num => num * 3) // -> Fail(6) * ); * ``` */ export declare const failMap: (fn: (a: E) => V) => (val: Validation) => Validation; /** * Checks whether a Validation is a Success. * @returns true if the Validation is a Success * ```typescript * pipe( * Validations.Success(2), * Validations.isSuccess() // -> true * ); * ``` */ export declare const isSuccess: (noArg?: undefined) => (val: Validation) => boolean; /** * Checks whether a Validation is a Fail. * @returns true if the Validation is a Fail * ```typescript * pipe( * Validations.Success(2), * Validations.isSuccess() // -> true * ); * ``` */ export declare const isFail: (noArg?: undefined) => (val: Validation) => boolean; /** * Gets the Fail value. * @returns the value of a Fail. * ```typescript * pipe( * Validations.Fail('test'), * Validations.fail() // -> 'test' * ); * ``` */ export declare const fail: (noArg?: undefined) => (val: Validation) => E; /** * Gets the Success value. * @returns the value of a Success. * ```typescript * pipe( * Validations.Success('test'), * Validations.success() // -> 'test' * ); * ``` */ export declare const success: (noArg?: undefined) => (val: Validation) => T; /** * Converts a Validation into an Either. * @returns a Left is given a Fail, a Right if given a Success * ```typescript * pipe( * Validations.Success('test'), * Validations.toEither() // -> Right('test') * ); * ``` */ export declare const toEither: (noArg?: undefined) => (val: Validation) => Either; /** * Converts a Validation into a Maybe. * @returns a Some if given a Success, a None otherwise * ```typescript * pipe( * Validations.Success('test'), * Validations.toMaybe() // -> Some('test') * ); * ``` */ export declare const toMaybe: (noArg?: undefined) => (val: Validation) => Maybe; /** * Performs an acc on a Validation see {@link https://github.com/monet/monet.js/blob/master/docs/VALIDATION.md} */ export declare const acc: (noArg?: undefined) => (val: Validation) => Validation; /** * Performs an ap on a Validation see {@link https://github.com/monet/monet.js/blob/master/docs/VALIDATION.md} */ export declare const ap: (eitherFn: Validation V>) => (validation: Validation) => Validation; /** * Flat maps a Success to a new Validation. * @alias successFlatMap * @alias flatMap * @alias chain * @param fn - the mapper function * @returns the flat mapped Validation * ```typescript * pipe( * Validations.Success('test'), * Validations.bind(str => Validations.Fail(new Error(str))) // -> Fail(Error) * ); * ``` */ export declare const bind: (fn: (a: T) => Validation) => (val: Validation) => Validation; /** * Flat maps a Success to a new Validation. * @alias successFlatMap * @alias bind * @alias flatMap * @param fn - the mapper function * @returns the flat mapped Validation * ```typescript * pipe( * Validations.Success('test'), * Validations.chain(str => Validations.Fail(new Error(str))) // -> Fail(Error) * ); * ``` */ export declare const chain: (fn: (a: T) => Validation) => (val: Validation) => Validation; /** * Flat maps a Success to a new Validation. * @alias flatMap * @alias bind * @alias chain * @param fn - the mapper function * @returns the flat mapped Validation * ```typescript * pipe( * Validations.Success('test'), * Validations.successFlatMap(str => Validations.Fail(new Error(str))) // -> Fail(Error) * ); * ``` */ export declare const successFlatMap: (fn: (a: T) => Validation) => (val: Validation) => Validation; /** * Creates a Success Validation. */ export declare const Success: ISuccessStatic; /** * Creates a Fail Validation. */ export declare const Fail: IFailStatic; /** * Maps a Success using a mapper function. * @alias map * @param fn - the mapper function * @returns the mapped Success, or an unchanged Fail * ```typescript * pipe( * Validations.Success(2), * Validations.successMap(num => num * 3) // -> Success(6) * ); * ``` */ export declare const successMap: (fn: (a: T) => V) => (val: Validation) => Validation; /** * Maps both sides of a Validation. * @alias bimap * @param fail - the mapper for a Fail * @param success - the mapper for a Success * @returns a mapped Validation * ```typescript * pipe( * Validations.Fail('fail'), * Validations.mapBoth( * str => str + '!', // -> Fail('fail!') * num => num.toString() * ) * ); * * pipe( * Validations.Success(5), * Validations.mapBoth( * str => str + '!', * num => num.toString() // -> Success('5') * ) * ); * ``` */ export declare const mapBoth: (fail: (a: E) => A, success: (b: T) => B) => (val: Validation) => Validation;