Module

x/functional/mod.ts>Pair

Common Functional Programming Algebraic data types for JavaScript that is compatible with most modern browsers and Deno.
Latest
variable Pair
import { Pair } from "https://deno.land/x/functional@v1.3.4/mod.ts";

Pair

The Pair type represents two values.

The Pair type implements the following algebras:

  • [x] Bifunctor
  • [x] Functor

Example

import Pair from "https://deno.land/x/functional@v1.3.2/library/Pair.js";

const pair = Pair(42, 42)
  .bimap(
    x => x * 2,
    x => x + 2
  );

assert(Pair.is(pair));
assert(pair.first === 84);
assert(pair.first === 44);