/** * Polymorphic functions for `newtype-ts`. * * **Warning**: These functions will allow you to break the contracts of * newtypes behind smart constructors. * * @since 0.15.0 */ import type { Endomorphism } from "fp-ts/Endomorphism"; import type { Functor, Functor1, Functor2, Functor3, Functor4 } from "fp-ts/Functor"; import type { HKT, Kind, Kind2, Kind3, Kind4, URIS, URIS2, URIS3, URIS4 } from "fp-ts/HKT"; import { type Newtype } from "newtype-ts"; /** * Pack a value into a newtype. * * @example * import { pack } from 'fp-ts-std/Newtype' * import { Milliseconds, mkMilliseconds } from 'fp-ts-std/Date' * * assert.strictEqual( * pack(123), * mkMilliseconds(123), * ) * * @category 3 Functions * @since 0.15.0 */ export declare const pack: = never>(x: A["_A"]) => A; /** * Unpack a value from a newtype. * * @example * import { unpack } from 'fp-ts-std/Newtype' * import { mkMilliseconds } from 'fp-ts-std/Date' * * assert.strictEqual( * unpack(mkMilliseconds(123)), * 123, * ) * * @category 3 Functions * @since 0.15.0 */ export declare const unpack: >(x: A) => A["_A"]; /** * Apply an effectful function over a newtype. * * @example * import { overF } from 'fp-ts-std/Newtype' * import * as O from 'fp-ts/Option' * import { Milliseconds, mkMilliseconds } from 'fp-ts-std/Date' * * const filterLongEnough = * overF(O.Functor)(O.fromPredicate(n => n > 1000)) * * assert.deepStrictEqual(filterLongEnough(mkMilliseconds(500)), O.none) * assert.deepStrictEqual(filterLongEnough(mkMilliseconds(1500)), O.some(mkMilliseconds(1500))) * * @category 2 Typeclass Methods * @since 0.15.0 */ export declare function overF(F: Functor4): (f: (x: A) => Kind4) => >(x: B) => Kind4; export declare function overF(F: Functor3): (f: (x: A) => Kind3) => >(x: B) => Kind3; export declare function overF(F: Functor2): (f: (x: A) => Kind2) => >(x: B) => Kind2; export declare function overF(F: Functor1): (f: (x: A) => Kind) => >(x: B) => Kind; export declare function overF(F: Functor): (f: (x: A) => HKT) => >(x: B) => HKT; /** * Apply an endomorphism over a newtype. Similar to functor map, but for * newtypes. * * @example * import { over } from 'fp-ts-std/Newtype' * import { mkMilliseconds } from 'fp-ts-std/Date' * import { multiply } from 'fp-ts-std/Number' * * assert.strictEqual( * over(multiply(2))(mkMilliseconds(3)), * mkMilliseconds(6), * ) * * @category 3 Functions * @since 0.15.0 */ export declare const over: (f: Endomorphism) => >(x: B) => B; //# sourceMappingURL=Newtype.d.ts.map