import type { Semaphore } from "../Semaphore"; import * as T from "../Task/_core"; import type { Ref } from "../XRef"; /** * A `XRefM` is a polymorphic, purely functional * description of a mutable reference. The fundamental operations of a `XRefM` * are `set` and `get`. `set` takes a value of type `A` and sets the reference * to a new value, requiring an environment of type `RA` and potentially * failing with an error of type `EA`. `get` gets the current value of the * reference and returns a value of type `B`, requiring an environment of type * `RB` and potentially failing with an error of type `EB`. * * When the error and value types of the `XRefM` are unified, that is, it is a * `XRefM[E, E, A, A]`, the `XRefM` also supports atomic `modify` and `update` * operations. * * Unlike `ZRef`, `XRefM` allows performing effects within update operations, * at some cost to performance. Writes will semantically block other writers, *while multiple readers can read simultaneously. */ export interface XRefM { /** * Folds over the error and value types of the `XRefM`. This is a highly * polymorphic method that is capable of arbitrarily transforming the error * and value types of the `XRefM`. For most use cases one of the more * specific combinators implemented in terms of `foldM` will be more * ergonomic but this method is extremely useful for implementing new * combinators. */ readonly foldM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ca: (_: C) => T.Task, bd: (_: B) => T.Task ) => XRefM; /** * Folds over the error and value types of the `XRefM`, allowing access to * the state in transforming the `set` value. This is a more powerful version * of `foldM` but requires unifying the environment and error types. */ readonly foldAllM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ec: (_: EB) => EC, ca: (_: C) => (_: B) => T.Task, bd: (_: B) => T.Task ) => XRefM; /** * Reads the value from the `XRefM`. */ readonly get: T.Task; /** * Writes a new value to the `XRefM`, with a guarantee of immediate * consistency (at some cost to performance). */ readonly set: (a: A) => T.Task; } export declare class DerivedAll implements XRefM { readonly value: Atomic; readonly getEither: (s: S) => T.Task; readonly setEither: (a: A) => (s: S) => T.Task; readonly _tag = "DerivedAll"; constructor( value: Atomic, getEither: (s: S) => T.Task, setEither: (a: A) => (s: S) => T.Task ); readonly foldM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ca: (_: C) => T.Task, bd: (_: B) => T.Task ) => XRefM; readonly foldAllM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ec: (_: EB) => EC, ca: (_: C) => (_: B) => T.Task, bd: (_: B) => T.Task ) => XRefM; get: T.Task; set: (a: A) => T.Task; } export declare class Derived implements XRefM { readonly value: Atomic; readonly getEither: (s: S) => T.Task; readonly setEither: (a: A) => T.Task; readonly _tag = "Derived"; constructor(value: Atomic, getEither: (s: S) => T.Task, setEither: (a: A) => T.Task); readonly foldM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ca: (_: C) => T.Task, bd: (_: B) => T.Task ) => XRefM; readonly foldAllM: ( ea: (_: EA) => EC, eb: (_: EB) => ED, ec: (_: EB) => EC, ca: (_: C) => (_: B) => T.Task, bd: (_: B) => T.Task ) => XRefM; get: T.Task; set: (a: A) => T.Task; } export declare class Atomic implements XRefM { readonly ref: Ref; readonly semaphore: Semaphore; readonly _tag = "Atomic"; constructor(ref: Ref, semaphore: Semaphore); readonly foldM: ( _ea: (_: never) => EC, _eb: (_: never) => ED, ca: (_: C) => T.Task, bd: (_: A) => T.Task ) => XRefM; readonly foldAllM: ( _ea: (_: never) => EC, _eb: (_: never) => ED, _ec: (_: never) => EC, ca: (_: C) => (_: A) => T.Task, bd: (_: A) => T.Task ) => XRefM; readonly get: T.Task; readonly set: (a: A) => T.Task; } export interface RefMRE extends XRefM {} export interface RefME extends XRefM {} export interface RefMR extends XRefM {} export interface RefM extends XRefM {} export declare const concrete: ( _: XRefM ) => Atomic | Derived | DerivedAll; //# sourceMappingURL=model.d.ts.map