Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/fun/mod.ts>state.state

A collection of algebraic data types, lenses, and schemables based on a light weight higher kinded type implementation. Written for deno.
Go to Latest
interface state.state
implements Kind
Re-export
import { type state } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { state } = state;

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.

Properties

readonly
kind: State<InOut<this, 1>, Out<this, 0>>
type alias state.state
Re-export
import { type state } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { state } = state;

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

definition: (e: E) => [A, E]
variable state.state
Re-export
import { state } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { state } = state;

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

function state.state
Re-export
import { state } from "https://deno.land/x/fun@v.2.0.0-alpha.11/mod.ts";
const { state } = state;

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

Examples

Example 1

import * as S from "./state.ts";

const state = S.state(1, 2);

const result = state(10); // [2, 1]