Skip to main content
Deno 2 is finally here 🎉️
Learn more
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.
Latest
import * as fun from "https://deno.land/x/fun@v2.0.0/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 Flatmappable for State. It contains the methods wrap, apply, map, join, and flatmap.

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>.

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.

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>.

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.

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

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

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

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

Construct a State<E, A> from a static value 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.