/** * @since 1.0.0 */ import type { Either } from "@fp-ts/core/Either"; import type { Chunk } from "@fp-ts/data/Chunk"; import type { Context } from "@fp-ts/data/Context"; import type { ChunkPatch } from "@fp-ts/data/Differ/ChunkPatch"; import type { ContextPatch } from "@fp-ts/data/Differ/ContextPatch"; import type { HashMapPatch } from "@fp-ts/data/Differ/HashMapPatch"; import type { HashSetPatch } from "@fp-ts/data/Differ/HashSetPatch"; import type { OrPatch } from "@fp-ts/data/Differ/OrPatch"; import type { HashMap } from "@fp-ts/data/HashMap"; import type { HashSet } from "@fp-ts/data/HashSet"; declare const TypeId: unique symbol; /** * @since 1.0.0 * @category symbol */ export type TypeId = typeof TypeId; /** * A `Differ` knows how to compare an old value and new value of * type `Value` to produce a patch of type `Patch` that describes the * differences between those values. A `Differ` also knows how to apply a patch * to an old value to produce a new value that represents the old value updated * with the changes described by the patch. * * A `Differ` can be used to construct a `FiberRef` supporting compositional * updates using the `FiberRef.makePatch` constructor. * * The `Differ` companion object contains constructors for `Differ` values for * common data types such as `Chunk`, `HashMap`, and `HashSet``. In addition, * `Differ`values can be transformed using the `transform` operator and combined * using the `orElseEither` and `zip` operators. This allows creating `Differ` * values for arbitrarily complex data types compositionally. * * @since 1.0.0 * @category models */ export interface Differ { readonly _id: TypeId; readonly _V: (_: Value) => Value; readonly _P: (_: Patch) => Patch; } export declare namespace Differ { namespace Or { type Patch = OrPatch; } namespace Context { type Patch = ContextPatch; } namespace Chunk { type Patch = ChunkPatch; } namespace HashMap { type Patch = HashMapPatch; } namespace HashSet { type Patch = HashSetPatch; } } /** * An empty patch that describes no changes. * * @since 1.0.0 * @category patch */ export declare const empty: (self: Differ) => Patch; /** * An empty patch that describes no changes. * * @since 1.0.0 * @category patch */ export declare const diff: { (differ: Differ, oldValue: Value, newValue: Value): Patch; (oldValue: Value, newValue: Value): (differ: Differ) => Patch; }; /** * Combines two patches to produce a new patch that describes the updates of * the first patch and then the updates of the second patch. The combine * operation should be associative. In addition, if the combine operation is * commutative then joining multiple fibers concurrently will result in * deterministic `FiberRef` values. * * @since 1.0.0 * @category patch */ export declare const combine: { (self: Differ, first: Patch, second: Patch): Patch; (first: Patch, second: Patch): (self: Differ) => Patch; }; /** * Applies a patch to an old value to produce a new value that is equal to the * old value with the updates described by the patch. * * @since 1.0.0 * @category patch */ export declare const patch: { (self: Differ, patch: Patch, oldValue: Value): Value; (patch: Patch, oldValue: Value): (self: Differ) => Value; }; /** * Constructs a new `Differ`. * * @since 1.0.0 * @category constructors */ export declare const make: (params: { readonly empty: Patch; readonly diff: (oldValue: Value, newValue: Value) => Patch; readonly combine: (first: Patch, second: Patch) => Patch; readonly patch: (patch: Patch, oldValue: Value) => Value; }) => Differ; /** * Constructs a differ that knows how to diff `Env` values. * * @since 1.0.0 * @category constructors */ export declare const environment: () => Differ, ContextPatch>; /** * Constructs a differ that knows how to diff a `Chunk` of values given a * differ that knows how to diff the values. * * @since 1.0.0 * @category constructors */ export declare const chunk: (differ: Differ) => Differ, ChunkPatch>; /** * Constructs a differ that knows how to diff a `HashMap` of keys and values given * a differ that knows how to diff the values. * * @since 1.0.0 * @category constructors */ export declare const hashMap: (differ: Differ) => Differ, HashMapPatch>; /** * Constructs a differ that knows how to diff a `HashSet` of values. * * @since 1.0.0 * @category constructors */ export declare const hashSet: () => Differ, HashSetPatch>; /** * Combines this differ and the specified differ to produce a differ that * knows how to diff the sum of their values. * * @since 1.0.0 * @category mutations */ export declare const orElseResult: { (self: Differ, that: Differ): Differ, OrPatch>; (that: Differ): (self: Differ) => Differ, OrPatch>; }; /** * Transforms the type of values that this differ knows how to differ using * the specified functions that map the new and old value types to each other. * * @since 1.0.0 * @category mutations */ export declare const transform: { (self: Differ, f: (value: Value) => Value2, g: (value: Value2) => Value): Differ; (f: (value: Value) => Value2, g: (value: Value2) => Value): (self: Differ) => Differ; }; /** * Constructs a differ that just diffs two values by returning a function that * sets the value to the new value. This differ does not support combining * multiple updates to the value compositionally and should only be used when * there is no compositional way to update them. * * @since 1.0.0 * @category mutations */ export declare const update: () => Differ A>; /** * A variant of `update` that allows specifying the function that will be used * to combine old values with new values. * * @since 1.0.0 * @category mutations */ export declare const updateWith: (f: (x: A, y: A) => A) => Differ A>; /** * Combines this differ and the specified differ to produce a new differ that * knows how to diff the product of their values. * * @since 1.0.0 * @category mutations */ export declare const zip: { (self: Differ, that: Differ): Differ; (that: Differ): (self: Differ) => Differ; }; export {}; //# sourceMappingURL=Differ.d.ts.map