/** * @since 2.0.0 */ import { Applicative2 } from './Applicative.js'; import { Apply2 } from './Apply.js'; import * as chainable from './Chain.js'; import { FromState2 } from './FromState.js'; import { Functor2 } from './Functor.js'; import { Monad2 } from './Monad.js'; import { Pointed2 } from './Pointed.js'; import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray.js'; /** * @category model * @since 2.0.0 */ export interface State { (s: S): [A, S]; } /** * Get the current state * * @category constructors * @since 2.0.0 */ export declare const get: () => State; /** * Set the state * * @category constructors * @since 2.0.0 */ export declare const put: (s: S) => State; /** * Modify the state by applying a function to the current state * * @category constructors * @since 2.0.0 */ export declare const modify: (f: (s: S) => S) => State; /** * Get a value which depends on the current state * * @category constructors * @since 2.0.0 */ export declare const gets: (f: (s: S) => A) => State; /** * `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. * * @category mapping * @since 2.0.0 */ export declare const map: (f: (a: A) => B) => (fa: State) => State; /** * @since 2.0.0 */ export declare const ap: (fa: State) => (fab: State B>) => State; /** * @category constructors * @since 2.0.0 */ export declare const of: (a: A) => State; /** * @category sequencing * @since 2.14.0 */ export declare const flatMap: { (f: (a: A) => State): (ma: State) => State; (ma: State, f: (a: A) => State): State; }; /** * @category sequencing * @since 2.0.0 */ export declare const flatten: (mma: State>) => State; /** * @category type lambdas * @since 2.0.0 */ export declare const URI = "State"; /** * @category type lambdas * @since 2.0.0 */ export type URI = typeof URI; declare module './HKT.js' { interface URItoKind2 { readonly [URI]: State; } } /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor2; /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: import("./HKT.js").Kind2<"State", E, (a: A) => B>) => import("./HKT.js").Kind2<"State", E, B>; /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed2; /** * @category instances * @since 2.10.0 */ export declare const Apply: Apply2; /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: (second: State) => (first: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, A>; /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: (second: State) => (first: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, B>; /** * @category instances * @since 2.7.0 */ export declare const Applicative: Applicative2; /** * @category instances * @since 2.10.0 */ export declare const Chain: chainable.Chain2; /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad2; /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @category combinators * @since 2.15.0 */ export declare const tap: { (self: State, f: (a: A) => State): State; (f: (a: A) => State): (self: State) => State; }; /** * @category instances * @since 2.11.0 */ export declare const FromState: FromState2; /** * Run a computation in the `State` monad, discarding the final state * * @since 2.8.0 */ export declare const evaluate: (s: S) => (ma: State) => A; /** * Run a computation in the `State` monad discarding the result * * @since 2.8.0 */ export declare const execute: (s: S) => (ma: State) => S; /** * @since 2.8.0 */ export declare const bindTo: (name: N) => (fa: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, { readonly [K in N]: A; }>; declare const let_: (name: Exclude, f: (a: A) => B) => (fa: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B; }>; export { /** * @since 2.13.0 */ let_ as let }; /** * @since 2.8.0 */ export declare const bind: (name: Exclude, f: (a: A) => import("./HKT.js").Kind2<"State", E, B>) => (ma: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B; }>; /** * @since 2.8.0 */ export declare const apS: (name: Exclude, fb: State) => (fa: import("./HKT.js").Kind2<"State", E, A>) => import("./HKT.js").Kind2<"State", E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B; }>; /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: (f: (index: number, a: A) => State) => (as: ReadonlyNonEmptyArray) => State>; /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: (f: (index: number, a: A) => State) => ((as: ReadonlyArray) => State>); /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: (f: (index: number, a: A) => State) => (as: ReadonlyArray) => State>; /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: (f: (a: A) => State) => ((as: ReadonlyArray) => State>); /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => State>; /** * Alias of `flatMap`. * * @category legacy * @since 2.0.0 */ export declare const chain: (f: (a: A) => State) => (ma: State) => State; /** * Alias of `tap`. * * @category legacy * @since 2.0.0 */ export declare const chainFirst: (f: (a: A) => State) => (ma: State) => State; /** * Use [`evaluate`](#evaluate) instead * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const evalState: (ma: State, s: S) => A; /** * Use [`execute`](#execute) instead * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const execState: (ma: State, s: S) => S; /** * This instance is deprecated, use small, specific instances instead. * For example if a function needs a `Functor` instance, pass `S.Functor` instead of `S.state` * (where `S` is from `import S from 'fp-ts/State'`) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const state: Monad2;