import { STM } from "@effect/core/stm/STM/definition/base"; import { FiberId } from "@effect/core/io/FiberId/definition"; import { Env } from "@tsplus/stdlib/service/Env"; import { Lazy, LazyArg } from "@tsplus/stdlib/data/Function"; import { Stack } from "@tsplus/stdlib/data/Stack"; import { TExit } from "@effect/core/stm/TExit/definition"; import { AtomicReference } from "@tsplus/stdlib/data/AtomicReference"; import { Exit } from "@effect/core/io/Exit/definition"; import { TRef } from "@effect/core/stm/TRef/definition"; import { Effect, EffectURI } from "@effect/core/io/Effect/definition"; import { STMTypeId } from "@effect/core/stm/STM/definition/base"; import { State } from "@effect/core/stm/STM/State"; import { TxnId } from "@effect/core/stm/STM/TxnId"; import type { Entry } from "@effect/core/stm/STM/Entry"; import { TryCommit } from "@effect/core/stm/STM/TryCommit"; import type { Scheduler } from "@effect/core/support/Scheduler"; export declare class STMBase implements STM { readonly _tag = "ICommit"; readonly [STMTypeId]: { _R: (_: never) => R; _E: (_: never) => E; _A: (_: never) => A; }; readonly [EffectURI]: { _R: (_: never) => R; _E: (_: never) => E; _A: (_: never) => A; }; get commit(): Effect; } export declare class STMEffect extends STMBase { readonly f: (journal: Journal, fiberId: FiberId, environment: Env) => A; readonly _stmtag = "STMEffect"; constructor(f: (journal: Journal, fiberId: FiberId, environment: Env) => A); } export declare class STMOnFailure extends STMBase { readonly stm: STM; readonly onFailure: (e: E) => STM; readonly _stmtag = "STMOnFailure"; constructor(stm: STM, onFailure: (e: E) => STM); apply(a: A): STM; } export declare class STMOnRetry extends STMBase { readonly stm: STM; readonly onRetry: Lazy>; readonly _stmtag = "STMOnRetry"; constructor(stm: STM, onRetry: Lazy>); apply(a: A): STM; } export declare class STMOnSuccess extends STMBase { readonly stm: STM; readonly apply: (a: A) => STM; readonly _stmtag = "STMOnSuccess"; constructor(stm: STM, apply: (a: A) => STM); } export declare class STMProvide extends STMBase { readonly stm: STM; readonly f: (env: Env) => Env; readonly _stmtag = "STMProvide"; constructor(stm: STM, f: (env: Env) => Env); } export declare class STMSucceedNow extends STMBase { readonly a: A; readonly _stmtag = "STMSucceedNow"; constructor(a: A); } export declare class STMSucceed extends STMBase { readonly a: Lazy; readonly _stmtag = "STMSucceed"; constructor(a: Lazy); } export declare const STMFailExceptionSym: unique symbol; export type STMFailExceptionSym = typeof STMFailExceptionSym; export declare class STMFailException { readonly e: E; readonly [STMFailExceptionSym]: STMFailExceptionSym; constructor(e: E); } /** * @tsplus static effect/core/stm/STM.Ops isFailException * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function isFailException(u: unknown): u is STMFailException; export declare const STMDieExceptionSym: unique symbol; export type STMDieExceptionSym = typeof STMDieExceptionSym; export declare class STMDieException { readonly e: E; readonly [STMDieExceptionSym]: STMDieExceptionSym; constructor(e: E); } /** * @tsplus static effect/core/stm/STM.Ops isDieException * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function isDieException(u: unknown): u is STMDieException; export declare const STMInterruptExceptionSym: unique symbol; export type STMInterruptExceptionSym = typeof STMInterruptExceptionSym; export declare class STMInterruptException { readonly fiberId: FiberId; readonly [STMInterruptExceptionSym]: STMInterruptExceptionSym; constructor(fiberId: FiberId); } /** * @tsplus static effect/core/stm/STM.Ops isInterruptException * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function isInterruptException(u: unknown): u is STMInterruptException; export declare const STMRetryExceptionSym: unique symbol; export type STMRetryExceptionSym = typeof STMRetryExceptionSym; export declare class STMRetryException { readonly [STMRetryExceptionSym]: STMRetryExceptionSym; } /** * @tsplus static effect/core/stm/STM.Ops isRetryException * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function isRetryException(u: unknown): u is STMRetryException; /** * Commits this transaction atomically. * @tsplus getter effect/core/stm/STM commit * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function commit(self: STM): Effect; /** * @tsplus static effect/core/stm/STM.Ops atomically * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function atomically(self: STM): Effect; /** * Executes the specified finalization transaction whether or * not this effect succeeds. Note that as with all STM transactions, * if the full transaction fails, everything will be rolled back. * @tsplus static effect/core/stm/STM.Aspects ensuring * @tsplus pipeable effect/core/stm/STM ensuring * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function ensuring(finalizer: STM): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Returns a value that models failure in the transaction. * @tsplus static effect/core/stm/STM.Ops fail * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function fail(e: E): STM; /** * Returns an `STM` effect that succeeds with the specified value. * @tsplus static effect/core/stm/STM.Ops succeed * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function succeed(a: A): STM; /** * Effectfully folds over the `STM` effect, handling both failure and * success. * @tsplus static effect/core/stm/STM.Aspects foldSTM * @tsplus pipeable effect/core/stm/STM foldSTM * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function foldSTM(g: (e: E) => STM, f: (a: A) => STM): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Maps the value produced by the effect. * @tsplus static effect/core/stm/STM.Aspects map * @tsplus pipeable effect/core/stm/STM map * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function map(f: (a: A) => B): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Sequentially zips this value with the specified one, discarding the first * element of the tuple. * @tsplus pipeable-operator effect/core/stm/STM > * @tsplus static effect/core/stm/STM.Aspects zipRight * @tsplus pipeable effect/core/stm/STM zipRight * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function zipRight(that: STM): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Sequentially zips this value with the specified one, combining the values * using the specified combiner function. * @tsplus static effect/core/stm/STM.Aspects zipWith * @tsplus pipeable effect/core/stm/STM zipWith * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function zipWith(that: STM, f: (a: A, b: A1) => A2): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Returns an `STM` effect that succeeds with the specified value. * @tsplus static effect/core/stm/STM.Ops sync * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function sync(a: LazyArg): STM; /** * Recovers from all errors. * @tsplus static effect/core/stm/STM.Aspects catchAll * @tsplus pipeable effect/core/stm/STM catchAll * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function catchAll(f: (e: E) => STM): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * Feeds the value produced by this effect to the specified function, * and then runs the returned effect as well to produce its results. * @tsplus static effect/core/stm/STM.Aspects flatMap * @tsplus pipeable effect/core/stm/STM flatMap * @tsplus location "@effect/core/stm/STM/definition/primitives" */ export declare function flatMap(f: (a: A) => STM): (self: import("@effect/core/stm/STM/definition/base").STM) => import("@effect/core/stm/STM/definition/base").STM; /** * @tsplus macro remove */ export declare function concreteSTM(_: STM): asserts _ is STMEffect | STMOnFailure | STMOnSuccess | STMOnRetry | STMSucceed | STMSucceedNow | STMProvide; export declare class STMDriver { readonly self: STM; readonly journal: Journal; readonly fiberId: FiberId; private yieldOpCount; private contStack; private envStack; constructor(self: STM, journal: Journal, fiberId: FiberId, r0: Env); private unwindStack; run(): TExit; } export declare function tryCommit(fiberId: FiberId, stm: STM, state: AtomicReference>, env: Env, scheduler: Scheduler): TryCommit; export declare function tryCommitSync(fiberId: FiberId, stm: STM, env: Env, scheduler: Scheduler): TryCommit; export declare function tryCommitAsync(journal: Journal | undefined, fiberId: FiberId, stm: STM, txnId: TxnId, state: AtomicReference>, env: Env, scheduler: Scheduler): (k: (_: Effect) => unknown) => void; export type Journal = Map, Entry>; export type JournalAnalysis = "I" | "RW" | "RO"; export type Todo = Lazy; /** * Creates a function that can reset the journal. */ export declare function prepareResetJournal(journal: Journal): Lazy; /** * Commits the journal. */ export declare function commitJournal(journal: Journal): void; /** * Analyzes the journal, determining whether it is valid and whether it is * read only in a single pass. Note that information on whether the * journal is read only will only be accurate if the journal is valid, due * to short-circuiting that occurs on an invalid journal. */ export declare function analyzeJournal(journal: Journal): JournalAnalysis; export declare const emptyTodoMap: import("@tsplus/stdlib/collections/HashMap").HashMap; /** * Atomically collects and clears all the todos from any `TRef` that * participated in the transaction. */ export declare function collectTodos(journal: Journal): Map; /** * Executes the todos in the current thread, sequentially. */ export declare function execTodos(todos: Map): void; /** * Runs all the todos. */ export declare function completeTodos(exit: Exit, journal: Journal, scheduler: Scheduler): TryCommit; /** * For the given transaction id, adds the specified todo effect to all * `TRef` values. */ export declare function addTodo(txnId: TxnId, journal: Journal, todoEffect: Todo): boolean; /** * Finds all the new todo targets that are not already tracked in the * `oldJournal`. */ export declare function untrackedTodoTargets(oldJournal: Journal, newJournal: Journal): Journal; /** * Determines if the journal is valid. */ export declare function isValid(journal: Journal): boolean; /** * Determines if the journal is invalid. */ export declare function isInvalid(journal: Journal): boolean; //# sourceMappingURL=primitives.d.ts.map