UNPKG

veffect

Version:

powerful TypeScript validation library built on the robust foundation of Effect combining exceptional type safety, high performance, and developer experience. Taking inspiration from Effect's functional principles, VEffect delivers a balanced approach tha

146 lines 3.83 kB
/** * @since 2.0.0 */ import type * as Option from "./Option.js"; import type * as STM from "./STM.js"; import type * as Types from "./Types.js"; /** * @since 2.0.0 * @category symbols */ export declare const TRefTypeId: unique symbol; /** * @since 2.0.0 * @category symbols */ export type TRefTypeId = typeof TRefTypeId; /** * A `TRef<A>` is a purely functional description of a mutable reference that can * be modified as part of a transactional effect. The fundamental operations of * a `TRef` are `set` and `get`. `set` transactionally sets the reference to a * new value. `get` gets the current value of the reference. * * NOTE: While `TRef<A>` provides the transactional equivalent of a mutable * reference, the value inside the `TRef` should be immutable. * * @since 2.0.0 * @category models */ export interface TRef<in out A> extends TRef.Variance<A> { /** * Note: the method is unbound, exposed only for potential extensions. */ modify<B>(f: (a: A) => readonly [B, A]): STM.STM<B>; } /** * @since 2.0.0 */ export declare namespace TRef { /** * @since 2.0.0 */ interface Variance<in out A> { readonly [TRefTypeId]: { readonly _A: Types.Invariant<A>; }; } } /** * @since 2.0.0 * @category mutations */ export declare const get: <A>(self: TRef<A>) => STM.STM<A>; /** * @since 2.0.0 * @category mutations */ export declare const getAndSet: { <A>(value: A): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, value: A): STM.STM<A>; }; /** * @since 2.0.0 * @category mutations */ export declare const getAndUpdate: { <A>(f: (a: A) => A): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, f: (a: A) => A): STM.STM<A>; }; /** * @since 2.0.0 * @category mutations */ export declare const getAndUpdateSome: { <A>(f: (a: A) => Option.Option<A>): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, f: (a: A) => Option.Option<A>): STM.STM<A>; }; /** * @since 2.0.0 * @category constructors */ export declare const make: <A>(value: A) => STM.STM<TRef<A>>; /** * @since 2.0.0 * @category mutations */ export declare const modify: { <A, B>(f: (a: A) => readonly [B, A]): (self: TRef<A>) => STM.STM<B>; <A, B>(self: TRef<A>, f: (a: A) => readonly [B, A]): STM.STM<B>; }; /** * @since 2.0.0 * @category mutations */ export declare const modifySome: { <A, B>(fallback: B, f: (a: A) => Option.Option<readonly [B, A]>): (self: TRef<A>) => STM.STM<B>; <A, B>(self: TRef<A>, fallback: B, f: (a: A) => Option.Option<readonly [B, A]>): STM.STM<B>; }; /** * @since 2.0.0 * @category mutations */ export declare const set: { <A>(value: A): (self: TRef<A>) => STM.STM<void>; <A>(self: TRef<A>, value: A): STM.STM<void>; }; /** * @since 2.0.0 * @category mutations */ export declare const setAndGet: { <A>(value: A): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, value: A): STM.STM<A>; }; /** * @since 2.0.0 * @category mutations */ export declare const update: { <A>(f: (a: A) => A): (self: TRef<A>) => STM.STM<void>; <A>(self: TRef<A>, f: (a: A) => A): STM.STM<void>; }; /** * @since 2.0.0 * @category mutations */ export declare const updateAndGet: { <A>(f: (a: A) => A): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, f: (a: A) => A): STM.STM<A>; }; /** * @since 2.0.0 * @category mutations */ export declare const updateSome: { <A>(f: (a: A) => Option.Option<A>): (self: TRef<A>) => STM.STM<void>; <A>(self: TRef<A>, f: (a: A) => Option.Option<A>): STM.STM<void>; }; /** * @since 2.0.0 * @category mutations */ export declare const updateSomeAndGet: { <A>(f: (a: A) => Option.Option<A>): (self: TRef<A>) => STM.STM<A>; <A>(self: TRef<A>, f: (a: A) => Option.Option<A>): STM.STM<A>; }; //# sourceMappingURL=TRef.d.ts.map