/** * Utility functions to accommodate `fp-ts/Applicative`. * * @since 0.12.0 */ import type { Applicative1, Applicative2, Applicative2C, Applicative3, Applicative3C, Applicative4 } from "fp-ts/Applicative"; import type { Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from "fp-ts/HKT"; /** * Conditional execution of an applicative. Helpful for conditional side effects * like logging. * * @example * import { pipe } from 'fp-ts/function' * import { Predicate } from 'fp-ts/Predicate' * import { when } from 'fp-ts-std/Applicative' * import * as IO from 'fp-ts/IO' * import * as IOE from 'fp-ts/IOEither' * import { log } from 'fp-ts/Console' * * const isInvalid: Predicate = n => n !== 42 * * pipe( * IOE.of(123), * IOE.chainFirstIOK(n => * when(IO.Applicative)(isInvalid(n))(log(n))), * ) * * @category 2 Typeclass Methods * @since 0.12.0 */ export declare function when(F: Applicative4): (b: boolean) => (x: Kind4) => Kind4; export declare function when(F: Applicative3): (b: boolean) => (x: Kind3) => Kind3; export declare function when(F: Applicative3C): (b: boolean) => (x: Kind3) => Kind3; export declare function when(F: Applicative2): (b: boolean) => (x: Kind2) => Kind2; export declare function when(F: Applicative2C): (b: boolean) => (x: Kind2) => Kind2; export declare function when(F: Applicative1): (b: boolean) => (x: Kind) => Kind; /** * The reverse of `when`. * * @example * import { pipe } from 'fp-ts/function' * import { Predicate } from 'fp-ts/Predicate' * import { unless } from 'fp-ts-std/Applicative' * import * as IO from 'fp-ts/IO' * import * as IOE from 'fp-ts/IOEither' * import { log } from 'fp-ts/Console' * * const isValid: Predicate = n => n === 42 * * pipe( * IOE.of(123), * IOE.chainFirstIOK(n => * unless(IO.Applicative)(isValid(n))(log(n))), * ) * * @category 2 Typeclass Methods * @since 0.12.0 */ export declare function unless(F: Applicative4): (b: boolean) => (x: Kind4) => Kind4; export declare function unless(F: Applicative3): (b: boolean) => (x: Kind3) => Kind3; export declare function unless(F: Applicative3C): (b: boolean) => (x: Kind3) => Kind3; export declare function unless(F: Applicative2): (b: boolean) => (x: Kind2) => Kind2; export declare function unless(F: Applicative2C): (b: boolean) => (x: Kind2) => Kind2; export declare function unless(F: Applicative1): (b: boolean) => (x: Kind) => Kind; /** * Convenient alias for `F.of(undefined)`. * * @example * import { pipe, constant } from 'fp-ts/function' * import { pass } from 'fp-ts-std/Applicative' * import * as O from 'fp-ts/Option' * import Option = O.Option * import { IO, Applicative } from 'fp-ts/IO' * import { log } from 'fp-ts/Console' * * const mcount: Option = O.some(123) * * const logCount: IO = pipe( * mcount, * O.match( * constant(pass(Applicative)), * log, * ), * ) * * @category 2 Typeclass Methods * @since 0.17.0 */ export declare function pass(F: Applicative4): Kind4; export declare function pass(F: Applicative3): Kind3; export declare function pass(F: Applicative2): Kind2; export declare function pass(F: Applicative1): Kind; //# sourceMappingURL=Applicative.d.ts.map