Skip to main content
Module

x/fun/mod.ts>pair.pair

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

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

Properties

readonly
kind: Pair<Out<this, 0>, Out<this, 1>>

Properties

readonly
kind: Pair<Out<this, 0>, B>
type alias pair.pair
Re-export
import { type pair } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { pair } = pair;

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.

The primary use fo Pair in this library is the target of a partition, where some type A is partitioned, either into [A, A], or [A, B] where B extends A.

Other uses will likely come when Arrows are implemented in fun.

definition: readonly [A, B]
variable pair.pair
Re-export
import { pair } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { pair } = pair;

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

type

Mappable<KindPair>

type

Bimappable<KindPair>

type

Foldable<KindPair>

type

Traversable<KindPair>
function pair.pair
Re-export
import { pair } from "https://deno.land/x/fun@v2.0.0/mod.ts";
const { pair } = pair;

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

Examples

Example 1

import * as P from "./pair.ts";

const nameAndAge = P.pair("Brandon", 37);

const name = P.getFirst(nameAndAge); // "Brandon"
const age = P.getSecond(nameAndAge); // 37

Parameters

first: A
second: B