/** * Utility functions to accommodate `fp-ts/Alternative`. * * @since 0.13.0 */ import type { Alternative, Alternative1, Alternative2, Alternative2C, Alternative3, Alternative3C, Alternative4 } from "fp-ts/Alternative"; import type { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from "fp-ts/HKT"; import type { Lazy } from "./Lazy"; /** * Conditionally lifts a value to an `Alternative` context or returns * empty/zero. The lazy value is evaluated only if the condition passes. * * @example * import { constant } from 'fp-ts/function' * import { pureIf } from 'fp-ts-std/Alternative' * import * as O from 'fp-ts/Option' * import { Predicate } from 'fp-ts/Predicate' * * const person = { name: 'Hodor', age: 40 } * const isMagicNumber: Predicate = n => n === 42 * * const mname = pureIf(O.Alternative)(isMagicNumber(person.age))(constant(person.name)) * * @category 2 Typeclass Methods * @since 0.13.0 */ export declare function pureIf(F: Alternative4): (x: boolean) => (y: Lazy) => Kind4; export declare function pureIf(F: Alternative3): (x: boolean) => (y: Lazy) => Kind3; export declare function pureIf(F: Alternative3C): (x: boolean) => (y: Lazy) => Kind3; export declare function pureIf(F: Alternative2): (x: boolean) => (y: Lazy) => Kind2; export declare function pureIf(F: Alternative2C): (x: boolean) => (y: Lazy) => Kind2; export declare function pureIf(F: Alternative1): (x: boolean) => (y: Lazy) => Kind; /** * Like `altAll`, but flaps an input across an array of functions to produce * the `Alternative` values, short-circuiting upon a non-empty value. Useful for * `Alternative` types without inherent laziness. * * @example * import { constant } from 'fp-ts/function' * import { altAllBy } from 'fp-ts-std/Alternative' * import * as O from 'fp-ts/Option' * * const f = altAllBy(O.Alternative) * * assert.deepStrictEqual( * f([constant(O.none), O.some])('foo'), * O.some('foo'), * ) * * @category 2 Typeclass Methods * @since 0.15.0 */ export declare function altAllBy(F: Alternative4): (fs: Array<(x: A) => Kind4>) => (x: A) => Kind4; export declare function altAllBy(F: Alternative3): (fs: Array<(x: A) => Kind3>) => (x: A) => Kind3; export declare function altAllBy(F: Alternative3C): (fs: Array<(x: A) => Kind3>) => (x: A) => Kind3; export declare function altAllBy(F: Alternative2): (fs: Array<(x: A) => Kind2>) => (x: A) => Kind2; export declare function altAllBy(F: Alternative2C): (fs: Array<(x: A) => Kind2>) => (x: A) => Kind2; export declare function altAllBy(F: Alternative1): (fs: Array<(x: A) => Kind>) => (x: A) => Kind; export declare function altAllBy(F: Alternative): (fs: Array<(x: A) => HKT>) => (x: A) => HKT; //# sourceMappingURL=Alternative.d.ts.map