import * as Chunk from "../Collections/Immutable/Chunk/core.js"; import * as Tp from "../Collections/Immutable/Tuple/index.js"; import { _A, _E, _R, _S1, _S2, _U, _W } from "../Effect/commons.js"; import type { EffectURI } from "../Effect/effect.js"; import * as E from "../Either/core.js"; import type { HasUnify } from "../Utils/index.js"; /** * `XPure[W, S1, S2, R, E, A]` is a purely functional description of a * computation that requires an environment `R` and an initial state `S1` and * may either fail with an `E` or succeed with an updated state `S2` and an `A` * along with in either case a log with entries of type `W`. Because of its * polymorphism `ZPure` can be used to model a variety of effects including * context, state, failure, and logging. */ export interface XPure extends HasUnify { readonly _tag: "XPure"; readonly [_S1]: (_: S1) => void; readonly [_S2]: () => S2; readonly [_U]: EffectURI; readonly [_W]: () => W; readonly [_E]: () => E; readonly [_A]: () => A; readonly [_R]: (_: R) => void; } export declare abstract class XPureBase implements XPure { readonly _tag = "XPure"; readonly [_S1]: (_: S1) => void; readonly [_S2]: () => S2; readonly [_U]: EffectURI; readonly [_W]: () => W; readonly [_E]: () => E; readonly [_A]: () => A; readonly [_R]: (_: R) => void; } /** * Extends this computation with another computation that depends on the * result of this computation by running the first computation, using its * result to generate a second computation, and running that computation. */ export declare function chain(f: (a: A) => XPure): (self: XPure) => XPure; /** * Extends this computation with another computation that depends on the * result of this computation by running the first computation, using its * result to generate a second computation, and running that computation. */ export declare function chain_(self: XPure, f: (a: A) => XPure): XPure; /** * Returns a computation that effectfully "peeks" at the success of this one. */ export declare function tap(f: (a: A) => XPure): (self: XPure) => XPure; /** * Returns a computation that effectfully "peeks" at the success of this one. */ export declare function tap_(self: XPure, f: (a: A) => XPure): XPure; /** * Constructs a computation that always succeeds with the specified value, * passing the state through unchanged. */ export declare function succeed(a: A): XPure; /** * Constructs a computation that logs w. */ export declare function log(w: W): XPure; /** * Constructs a computation that logs w. */ export declare function logWith(f: () => W): XPure; /** * Constructs a computation that always succeeds with the specified value, * passing the state through unchanged. */ export declare function fail(a: E): XPure; /** * Extends this computation with another computation that depends on the * result of this computation by running the first computation, using its * result to generate a second computation, and running that computation. */ export declare function map_(self: XPure, f: (a: A) => B): XPure; /** * Extends this computation with another computation that depends on the * result of this computation by running the first computation, using its * result to generate a second computation, and running that computation. */ export declare function map(f: (a: A) => B): (self: XPure) => XPure; /** * Recovers from errors by accepting one computation to execute for the case * of an error, and one computation to execute for the case of success. */ export declare function foldM_(self: XPure, failure: (e: E) => XPure, success: (a: A) => XPure): XPure; /** * Recovers from errors by accepting one computation to execute for the case * of an error, and one computation to execute for the case of success. */ export declare function foldM(failure: (e: E) => XPure, success: (a: A) => XPure): (self: XPure) => XPure; /** * Folds over the failed or successful results of this computation to yield * a computation that does not fail, but succeeds with the value of the left * or righr function passed to `fold`. */ export declare function fold(failure: (e: E) => B, success: (a: A) => C): (self: XPure) => XPure; /** * Folds over the failed or successful results of this computation to yield * a computation that does not fail, but succeeds with the value of the left * or righr function passed to `fold`. */ export declare function fold_(self: XPure, failure: (e: E) => B, success: (a: A) => C): XPure; /** * Recovers from all errors. */ export declare function catchAll(failure: (e: E) => XPure): (self: XPure) => XPure; /** * Recovers from all errors. */ export declare function catchAll_(self: XPure, failure: (e: E) => XPure): XPure; /** * Returns a computation whose error and success channels have been mapped * by the specified functions, `f` and `g`. */ export declare function bimap(f: (e: E) => E1, g: (a: A) => A1): (self: XPure) => XPure; /** * Returns a computation whose error and success channels have been mapped * by the specified functions, `f` and `g`. */ export declare function bimap_(self: XPure, f: (e: E) => E1, g: (a: A) => A1): XPure; /** * Transforms the error type of this computation with the specified * function. */ export declare function mapError(f: (e: E) => E1): (self: XPure) => XPure; /** * Transforms the error type of this computation with the specified * function. */ export declare function mapError_(self: XPure, f: (e: E) => E1): XPure; /** * Constructs a computation from the specified modify function. */ export declare function modify(f: (s: S1) => Tp.Tuple<[S2, A]>): XPure; /** * Constructs a computation from the specified modify function. */ export declare function set(s: S): XPure; /** * Constructs a computation from the specified update function. */ export declare function update(f: (s: S1) => S2): XPure; /** * Constructs a computation that always returns the `Unit` value, passing the * state through unchanged. */ export declare const unit: XPure; /** * Transforms the initial state of this computation` with the specified * function. */ export declare function contramapInput(f: (s: S0) => S1): (self: XPure) => XPure; /** * Transforms the initial state of this computation` with the specified * function. */ export declare function provideSome(f: (s: R0) => R1): (self: XPure) => XPure; /** * Provides this computation with its required environment. */ export declare function provideAll(r: R): (self: XPure) => XPure; /** * Provides this computation with its required environment. */ export declare function provideAll_(self: XPure, r: R): XPure; /** * Provides some of the environment required to run this effect, * leaving the remainder `R0` and combining it automatically using spread. */ export declare function provide(r: R): (next: XPure) => XPure; /** * Get the state monadically */ export declare function getM(f: (_: S1) => XPure): XPure; /** * Get the state with the function f */ export declare function get(f: (_: S) => A): XPure; /** * Access the environment monadically */ export declare function accessM(f: (_: R) => XPure): XPure; /** * Access the environment with the function f */ export declare function access(f: (_: R) => A): XPure; /** * Access the environment */ export declare function environment(): XPure; /** * Returns a computation whose failure and success have been lifted into an * `Either`. The resulting computation cannot fail, because the failure case * has been exposed as part of the `Either` success case. */ export declare function either(self: XPure): XPure>; /** * Executes this computation and returns its value, if it succeeds, but * otherwise executes the specified computation. */ export declare function orElseEither(that: () => XPure): (self: XPure) => XPure>; /** * Executes this computation and returns its value, if it succeeds, but * otherwise executes the specified computation. */ export declare function orElseEither_(self: XPure, that: () => XPure): XPure>; /** * Combines this computation with the specified computation, passing the * updated state from this computation to that computation and combining the * results of both using the specified function. */ export declare function zipWith(that: XPure, f: (a: A, b: B) => C): (self: XPure) => XPure; /** * Combines this computation with the specified computation, passing the * updated state from this computation to that computation and combining the * results of both using the specified function. */ export declare function zipWith_(self: XPure, that: XPure, f: (a: A, b: B) => C): XPure; /** * Combines this computation with the specified computation, passing the * updated state from this computation to that computation and combining the * results of both into a tuple. */ export declare function zip(that: XPure): (self: XPure) => XPure>; /** * Combines this computation with the specified computation, passing the * updated state from this computation to that computation and combining the * results of both into a tuple. */ export declare function zip_(self: XPure, that: XPure): XPure>; /** * Suspend a computation, useful in recursion */ export declare function suspend(f: () => XPure): XPure; /** * Lift a sync (non failable) computation */ export declare function succeedWith(f: () => A): XPure; /** * Lift a sync (non failable) computation */ export declare function tryCatch(onThrow: (u: unknown) => E): (f: () => A) => XPure; /** * Runs this computation with the specified initial state, returning both the * log and either all the failures that occurred or the updated state and the * result. */ export declare function runAll_(self: XPure, s: S1): Tp.Tuple<[Chunk.Chunk, E.Either>]>; /** * Runs this computation with the specified initial state, returning either a * failure or the updated state and the result */ export declare function runAll(s: S1): (self: XPure) => Tp.Tuple<[Chunk.Chunk, E.Either>]>; /** * Runs this computation to produce its result. */ export declare function run(self: XPure): A; /** * Runs this computation with the specified initial state, returning both * the updated state and the result. */ export declare function runState_(self: XPure, s: S1): Tp.Tuple<[S2, A]>; /** * Runs this computation with the specified initial state, returning both * the updated state and the result. * * @ets_data_first runState_ */ export declare function runState(s: S1): (self: XPure) => Tp.Tuple<[S2, A]>; /** * Runs this computation to produce its result or the first failure to * occur. */ export declare function runEither(self: XPure): E.Either; /** * Runs this computation to produce its result and the log. */ export declare function runLog(self: XPure): Tp.Tuple<[Chunk.Chunk, A]>; /** * Runs this computation with the specified initial state, returning the * result and discarding the updated state. */ export declare function runResult_(self: XPure, s: S1): A; /** * Runs this computation with the specified initial state, returning the * result and discarding the updated state. */ export declare function runResult(s: S1): (self: XPure) => A; //# sourceMappingURL=core.d.ts.map