// ets_tracing: off import type * as Tp from "@effect-ts/system/Collections/Immutable/Tuple" import * as F from "@effect-ts/system/XPure" import type { XState } from "./definition.js" /** * Combines this computation with the specified computation. */ export const zip: ( fb: XState ) => (fa: XState) => XState> = F.zip /** * 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 const chain: ( f: (a: A) => XState ) => (self: XState) => XState = F.chain /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` * whose argument and return types use the type constructor `F` to represent * some computational context. */ export const map: (f: (a: A) => B) => (self: XState) => XState = F.map /** * Succeed with a value A */ export const succeed: (a: A) => XState = F.succeed /** * Run the computation with input S returning updated state and output */ export const run = (s: S) => (self: XState): Tp.Tuple<[S, A]> => F.runState_(self, s) /** * Run the computation with input S returning the updated state and discarding the output */ export const runState = (s: S) => (self: XState): S => F.runState_(self, s)[0] /** * Run the computation with input S returning the state and discarding the updated state */ export const runResult = (r: S) => (self: XState): A => F.runResult(r)(self) /** * Returns a computation that effectfully "peeks" at the success of this one. */ export const tap: ( f: (a: A) => XState ) => (self: XState) => XState = F.tap