Skip to content

Pair

Pair<A, B> = readonly [A, B]

Defined in: Core/Pair.ts:22

Pair<A, B> represents a pair of two values that are always both present. It is a typed alias for readonly [A, B].

Use Pair when two values always travel together through a pipeline and you want to transform either or both sides without destructuring.

A

B

import { Pair, pipe } from "@pplnd/core";

const entry = Pair.make("alice", 42);

pipe(
  entry,
  Pair.mapFirst((name) => name.toUpperCase()),
  Pair.mapSecond((score) => score * 2),
  Pair.merge((name, score) => `${name}: ${score}`),
); // "ALICE: 84"