Skip to main content
Module

x/fun/initializable.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/initializable.ts";

This file contains the type and utilities for the Initializable algebraic data structure. A type that implements Initializable has a concept of "empty" represented by the init method and a concept to combine represented by the combine method. In other functional libraries and languages Initializable is called Monoid.

Functions

Create an Initializable fixed to a concrete value A. This operates like init from Combinable in other functional libraries.

Create a dual Initializable from an existing initializable. This effectively switches the order of application of the original Initializable.

Given an Initializable, create a function that will iterate through an array of values and combine them. This is not much more than Array.fold(combine).

Create a initializable that works like Array.join, inserting middle between every two values that are combineenated. This can have some interesting results.

Create an Initializable fixed to a struct using nested Initializables to create the init values within.

Create an Initializable fixed to a tuple using nested Initializables to create the init values within.

Interfaces

A Initializable structure has the method init.

Type Aliases

A type for Initializable over any fixed value, useful as an extension target for functions that take any Initializable and do not need to unwrap the type.

A type level unwrapor, used to pull the inner type from a Combinable.