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

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

Variables

The canonical Bifunctor instance for Pair. Contains the bimap and mapLeft methods.

The canonical Comonad instance for Pair. Contains the extract, extend, and map methods.

The canonical Extend instance for Pair. Contains the extend and map methods.

The canonical Foldable instance for Pair. Contains the reduce method.

The canonical Functor instance for Pair. Contains the map method.

The canonical Traversable instance for Pair. Contains the map, reduce, and traverse methods.

Functions

Creates a new pair by mapping first through the fai function and second through the fbj function.

Creates a pair from a single type

Creates a new pair by constructing a first value from the whole pair and keeping the second value from the original pair. Can be used somewhat like a superpowered Reader.

Just like the first function, extract returns the first value in a pair.

A curried form of the pair constructor, starting with the first value of a pair.

Extracts the first value from a Pair.

Creates a Monad instance for Pair where the second parameter is concatenated according to the Monoid instance passed in.

Extracts the second value from a Pair.

Creates a Show instance for a pair, wrapping the Show instances provided for the first and second values.

Creates a new Pair with the same second value and a new first value determined by the output of the fai function.

Creates a new Pair with the same first value and a new second value determined by the output of the fbj function.

Apply a function in the first position of a pair to a value in the second position of a pair.

Apply a function in the first position of a pair to a value in the second position of a pair.

Creates a Pair from two values first and second with types A and B respectively. Used to quickly construct a Pair.

Reduces a pair with an initial value, also passing the second value into the reducer as well.

A curried form of the pair constructor, starting with the second value of a pair.

Creates a new Pair with the first and second values swapped.

Traverse a pair using another algebraic structure's Applicative.

Interfaces

Specifies Pair as a Higher Kinded Type, with covariant parameters A and B corresponding to the 0th and 1st index of any Substitutions.

A Kind implementation used to fix the second parameter in a Pair. Otherwise it operates the same as Pair does.

Type Aliases

Pair represents a pair of values. This is equivalent to a Tuple of length two, the Separated type in fp-ts, and any other type that contains exactly two covariant other types.