import { Monad } from './Monad'; export interface StateCallback { (s: S): [A, S]; } /** * get the state from the internals of the monad */ export declare const get: () => State; /** * put */ export declare const put: (s: S) => State; /** * modify the state * @summary (S → S) → State */ export declare const modify: (f: (s: S) => S) => State; /** * gets applies a function to the state putting using the result * as the result of the computation. * @summary (S → A) → State */ export declare const gets: (f: (s: S) => A) => State; /** * state create a new State monad */ export declare const state: (a: A) => State; /** * State is a monadic class that we use to hold information that changes * during computation. * * This implementation is influenced by: * @link https://en.wikipedia.org/wiki/Monad_(functional_programming)#State_monads * @property {s → (a, s)} a */ export declare class State implements Monad { f: StateCallback; constructor(f: StateCallback); static get: () => State; static put: (s: S) => State; static modify: (f: (s: S) => S) => State; static gets: (f: (s: S) => A) => State; static state: (a: A) => State; /** * of wraps a value in the State monad. * @summary A → State */ of(a: A): State; /** * map * @summary State → (A → B) → State */ map(f: (a: A) => B): State; /** * join replaces the outer State with an inner State */ join(): State; /** * chain */ chain(f: (a: A) => State): State; /** * evaluate the State returning the final value */ evaluate(s: S): A; /** * execute the State returning the final state. */ execute(s: S): S; /** * run the State yielding the final value and state. * @summary State → S → {A,S} */ run(s: S): [A, S]; }