Pair(3) OCaml library Pair(3)

# [NAME](#NAME)

Pair - Operations on pairs.

# [Module](#Module)

Module Pair

# [Documentation](#Documentation)

Module **Pair**  
: **sig end**

Operations on pairs.

**Since** 5.4

## [Pairs](#Pairs)

*type* **('a, 'b)** *t* = **'a * 'b**

The type for pairs.

*val make* : **'a -&gt; 'b -&gt; 'a * 'b**

**make a b** is the pair **(a, b)** .

*val fst* : **'a * 'b -&gt; 'a**

**fst (a, b)** is **a** .

*val snd* : **'a * 'b -&gt; 'b**

**snd (a, b)** is **b** .

*val swap* : **'a * 'b -&gt; 'b * 'a**

**swap (a, b)** is **(b, a)** .

## [Iterators](#Iterators)

*val fold* : **('a -&gt; 'b -&gt; 'c) -&gt; 'a * 'b -&gt; 'c**

**fold f (a, b)** applies **f** to **a** and **b** .

*val map* : **('a -&gt; 'c) -&gt; ('b -&gt; 'd) -&gt; 'a * 'b -&gt; 'c * 'd**

**map f g (a, b)** applies **f** to **a** and **g** to **b** .

*val iter* : **('a -&gt; unit) -&gt; ('b -&gt; unit) -&gt; 'a * 'b -&gt; unit**

**iter f g (a, b)** first applies **f** to **a** , and then **g** to **b** .

*val map\_fst* : **('a -&gt; 'c) -&gt; 'a * 'b -&gt; 'c * 'b**

**map\_fst f p** applies **f** to **p** 's first component.

*val map\_snd* : **('b -&gt; 'c) -&gt; 'a * 'b -&gt; 'a * 'c**

**map\_snd f p** applies **f** to **p** 's second component.

## [Predicates and comparisons](#Predicates_and_comparisons)

*val equal* : **('a -&gt; 'a -&gt; bool) -&gt; ('b -&gt; 'b -&gt; bool) -&gt; 'a * 'b -&gt; 'a * 'b -&gt; bool**

**equal eqa eqb (a1, b1) (a2, b2)** is **true** if and only if **eqa a1 a2** and **eqb b1 b2** are both **true** .

*val compare* : **('a -&gt; 'a -&gt; int) -&gt; ('b -&gt; 'b -&gt; int) -&gt; 'a * 'b -&gt; 'a * 'b -&gt; int**

**compare cmpa cmpb** is a total order on pairs using **cmpa** to compare the first component, and **cmpb** to compare the second component. It is implemented by a lexicographic order.

2026-10-23 OCamldoc

---

Document: Pair(3o) from ocaml 5.5.2-r0 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
