Skip to main content
Module

x/fun/state.ts

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
import * as fun from "https://deno.land/x/fun@v.2.0.0-alpha.11/state.ts";

The State module contains the State structure. The purpose of State is to have modifiable date in an immutable workflow. This structure must preserve purity, so that subsequent executions of a state workflow with the same initial conditions produce the exact same results.

Variables

The canonical implementation of Monad for State. It contains the methods of, ap, map, join, and chain.

Functions

Apply the A value of State<E, A> to the (a: A) => I value of State<E, (a: A) => I>, producing a State<E, I>.

Pass the A value in a State<S, A> into a function (a: A) => State<S, I>. This results in a new State<S, I>.

Extract the result value A by executing State<S, A> with an S value.

Extract the ending state value S by executing State<S, A> with an S value.

Construct a State<E, A> from a function E => A.

An instance of Id that makes the State structure a Category. This is often used at the beginning of a State workflow to specify the type of data within a State structure.

Collapse nested State<E, State<E, A>> into State<E, A>.

Map over the covariant value A in State<E, A>.

Construct a State<E, void> from a function E => E.

Construct a State<E, A> from a static value A.

Construct a State<E, void> from a static state value E.

Construct a trivial State<E, A> from values E and A.

Interfaces

Specifies State as a Higher Kinded Type, with covariant parameter A in the 0th index of any substitutions and invariant parameter E in the 0th parameter of any substitutions.

Type Aliases

The State<E, A> type represents the core State structure. The input/output variable E is invariant, and the output variable A is covariant.