DocsPlaygroundBlogCommunityPackages
  • Playground
  • Blog
  • Community
  • Packages
  • X
  • Bluesky
  • GitHub
  • Forum
Language ManualAPISyntax LookupReact
Overview
Stdlib
submodules
  • Array
  • ArrayBuffer
  • AsyncIterator
  • BigInt
  • BigInt64Array
    • Constants
    BigUint64Array
    • Constants
  • Bool
  • Console
  • DataView
  • Date
    • UTC
  • Dict
  • Error
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • Exn
  • Float
    • Constants
    Float32Array
    • Constants
    Float64Array
    • Constants
    Int
    • Ref
    • Bitwise
    • Constants
    Int16Array
    • Constants
    Int32Array
    • Constants
    Int8Array
    • Constants
  • IntervalId
  • Intl
    • Segments
    • Segmenter
    • RelativeTimeFormat
    • PluralRules
    • NumberFormat
      • Grouping
    • Locale
    • ListFormat
    • DateTimeFormat
    • Collator
    • Common
  • Iterator
  • JSON
    • Decode
    • Encode
    • Classify
    JsError
    • URIError
    • TypeError
    • SyntaxError
    • ReferenceError
    • RangeError
    • EvalError
  • JsExn
  • Lazy
  • List
  • Map
  • Math
    • Int
    • Constants
  • Null
  • Nullable
  • Object
  • Option
  • Ordering
  • Pair
    • t
      t
    • v
      first
    • v
      second
    • v
      ignore
    • v
      equal
    • v
      compare
  • Promise
  • RegExp
    • Result
  • Result
  • Set
  • String
  • Symbol
  • TimeoutId
  • Type
    • Classify
  • TypedArray
  • Uint16Array
    • Constants
    Uint32Array
    • Constants
    Uint8Array
    • Constants
    Uint8ClampedArray
    • Constants
  • WeakMap
  • WeakSet
  • Docs / API / Stdlib / Pair

    Pair

    This module provides functions to work with pairs, which are 2-element tuples.

    t

    RESCRIPT
    type t<'a, 'b> = ('a, 'b)

    first

    RESCRIPT
    let first: (('a, 'b)) => 'a

    first(pair) returns the first element of a pair.

    Examples

    RESCRIPT
    Pair.first((1, 2)) == 1

    second

    RESCRIPT
    let second: (('a, 'b)) => 'b

    second(pair) returns the second element of a pair.

    Examples

    RESCRIPT
    Pair.second((1, 2)) == 2

    ignore

    RESCRIPT
    let ignore: ('a, 'b) => unit

    ignore(pair) ignores the provided pair and returns unit.

    This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.

    equal

    RESCRIPT
    let equal: ( ('a, 'b), ('c, 'd), ('a, 'c) => bool, ('b, 'd) => bool, ) => bool

    equal(pair1, pair2, f1, f2) check equality of pair2 and pair2 using f1 for equality on the first element and f2 for equality on the second element.

    Examples

    RESCRIPT
    Pair.equal((1, "test"), (1, "test"), Int.equal, String.equal) == true Pair.equal((1, "test"), (2, "test"), Int.equal, String.equal) == false

    compare

    RESCRIPT
    let compare: ( ('a, 'b), ('c, 'd), ('a, 'c) => float, ('b, 'd) => float, ) => float

    compare(pair1, pair2, f1, f2) compares two pairs, using f1 to compare the first element and f2 to compare the second element. Ordering is based on the first element, if they are equal, the second element is compared.

    Examples

    RESCRIPT
    Pair.compare((1, "a"), (1, "a"), Int.compare, String.compare) == Ordering.equal Pair.compare((1, "a"), (1, "b"), Int.compare, String.compare) == Ordering.less Pair.compare((2, "a"), (1, "b"), Int.compare, String.compare) == Ordering.greater
    Types and values
    • t
      t
    • v
      first
    • v
      second
    • v
      ignore
    • v
      equal
    • v
      compare

    © 2025 The ReScript Project

    About
    • Community
    • ReScript Association
    Find us on