Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Usage

import * as fun from "https://raw.githubusercontent.com/baetheus/fun/main/combinable.ts";

Combinable is a structure that can be combine two fixed values. Some examples of Combinable are Array.combine, addition for numbers, or merging of two structs by combining their internal values.

§Functions

constant

Create a combinable that always returns the given value, ignoring anything that it is combineenated with.

dual

Get the "Dual" of an existing Combinable. This effectively reverses the order of the input combinable's application. For example, the dual of the "first" combinable is the "last" combinable. The dual of (boolean, ||) is itself.

first

Get an Combinable over A that always returns the first parameter supplied to combine (confusingly this is actually the last parameter since combine is in curried form).

fromCombine

Create a Combinable from a Combine and an init function.

getCombineAll

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

intercalcate

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

last

Get an Combinable over A that always returns the last parameter supplied to combine (confusingly this is actually the first parameter since combine is in curried form).

max

Create a combinable fron an instance of Sortable that returns that maximum for the type being ordered. This Combinable functions identically to max from Sortable.

min

Create a combinable fron an instance of Sortable that returns that minimum for the type being ordered. This Combinable functions identically to min from Sortable.

struct

Get a Combinable from a struct of combinables. The resulting combinable will operate over similar shaped structs applying the input combinables applying each based on its position,

tuple

Get a Combinable from a tuple of combinables. The resulting combinable will operate over tuples applying the input combinables applying each based on its position,

§Interfaces

Combinable

Combinable is a structure that allows the combination of two concrete values of A into a single value of A. In other functional libraries this is called a Semigroup.

§Type Aliases

AnyCombinable

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

Combine

The Combine function in a Combinable.

TypeOf

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