Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • X
  • Bluesky
  • GitHub
  • Forum
Belt Module
Overview
Belt
submodules
  • Array
  • Float
  • HashMap
    • String
    • Int
    HashSet
    • String
    • Int
    Id
    • MakeHashable
    • MakeHashableU
    • MakeComparable
    • MakeComparableU
  • Int
  • List
  • Map
    • Dict
    • String
    • Int
    MutableMap
    • String
    • Int
  • MutableQueue
  • MutableSet
    • String
    • Int
  • MutableStack
  • Option
  • Range
  • Result
  • Set
    • Dict
    • String
    • Int
    SortArray
    • String
    • Int
    API / Belt / Map / String

    String

    key

    RESCRIPT
    type key = string

    t

    RESCRIPT
    type t<'value>

    The type of maps from type key to type 'value.

    empty

    RESCRIPT
    let empty: t<'v>

    isEmpty

    RESCRIPT
    let isEmpty: t<'v> => bool

    has

    RESCRIPT
    let has: (t<'v>, key) => bool

    cmpU

    Deprecated

    Use cmp instead

    RESCRIPT
    let cmpU: (t<'v>, t<'v>, ('v, 'v) => int) => int

    cmp

    RESCRIPT
    let cmp: (t<'v>, t<'v>, ('v, 'v) => int) => int

    eqU

    Deprecated

    Use eq instead

    RESCRIPT
    let eqU: (t<'v>, t<'v>, ('v, 'v) => bool) => bool

    eq

    RESCRIPT
    let eq: (t<'v>, t<'v>, ('v, 'v) => bool) => bool

    eq(m1, m2) tests whether the maps m1 and m2 are equal, that is, contain equal keys and associate them with equal data.

    findFirstByU

    Deprecated

    Use findFirstBy instead

    RESCRIPT
    let findFirstByU: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>

    findFirstBy

    RESCRIPT
    let findFirstBy: (t<'v>, (key, 'v) => bool) => option<(key, 'v)>

    findFirstBy(m, p) uses funcion f to find the first key value pair to match predicate p.

    RESCRIPT
    let s0 = fromArray(~id=module(IntCmp), [(4, "4"), (1, "1"), (2, "2,"(3, ""))]) findFirstBy(s0, (k, v) => k == 4) == option((4, "4"))

    forEachU

    Deprecated

    Use forEach instead

    RESCRIPT
    let forEachU: (t<'v>, (key, 'v) => unit) => unit

    forEach

    RESCRIPT
    let forEach: (t<'v>, (key, 'v) => unit) => unit

    forEach(m, f) applies f to all bindings in map m. f receives the key as first argument, and the associated value as second argument. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.

    reduceU

    Deprecated

    Use reduce instead

    RESCRIPT
    let reduceU: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2

    reduce

    RESCRIPT
    let reduce: (t<'v>, 'v2, ('v2, key, 'v) => 'v2) => 'v2

    reduce(m, a, f) computes (f kN dN ... (f k1 d1 a)...), where k1 ... kN are the keys of all bindings in m (in increasing order), and d1 ... dN are the associated data.

    everyU

    Deprecated

    Use every instead

    RESCRIPT
    let everyU: (t<'v>, (key, 'v) => bool) => bool

    every

    RESCRIPT
    let every: (t<'v>, (key, 'v) => bool) => bool

    every(m, p) checks if all the bindings of the map satisfy the predicate p. Order unspecified

    someU

    Deprecated

    Use some instead

    RESCRIPT
    let someU: (t<'v>, (key, 'v) => bool) => bool

    some

    RESCRIPT
    let some: (t<'v>, (key, 'v) => bool) => bool

    some(m, p) checks if at least one binding of the map satisfy the predicate p. Order unspecified

    size

    RESCRIPT
    let size: t<'v> => int

    toList

    RESCRIPT
    let toList: t<'v> => list<(key, 'v)>

    In increasing order.

    toArray

    RESCRIPT
    let toArray: t<'v> => array<(key, 'v)>

    fromArray

    RESCRIPT
    let fromArray: array<(key, 'v)> => t<'v>

    keysToArray

    RESCRIPT
    let keysToArray: t<'v> => array<key>

    valuesToArray

    RESCRIPT
    let valuesToArray: t<'v> => array<'v>

    minKey

    RESCRIPT
    let minKey: t<'a> => option<key>

    minKeyUndefined

    RESCRIPT
    let minKeyUndefined: t<'a> => Js.undefined<key>

    maxKey

    RESCRIPT
    let maxKey: t<'a> => option<key>

    maxKeyUndefined

    RESCRIPT
    let maxKeyUndefined: t<'a> => Js.undefined<key>

    minimum

    RESCRIPT
    let minimum: t<'v> => option<(key, 'v)>

    minUndefined

    RESCRIPT
    let minUndefined: t<'v> => Js.undefined<(key, 'v)>

    maximum

    RESCRIPT
    let maximum: t<'v> => option<(key, 'v)>

    maxUndefined

    RESCRIPT
    let maxUndefined: t<'v> => Js.undefined<(key, 'v)>

    get

    RESCRIPT
    let get: (t<'v>, key) => option<'v>

    getUndefined

    RESCRIPT
    let getUndefined: (t<'v>, key) => Js.undefined<'v>

    getWithDefault

    RESCRIPT
    let getWithDefault: (t<'v>, key, 'v) => 'v

    getExn

    RESCRIPT
    let getExn: (t<'v>, key) => 'v

    checkInvariantInternal

    RESCRIPT
    let checkInvariantInternal: t<'a> => unit

    raise when invariant is not held

    remove

    RESCRIPT
    let remove: (t<'v>, key) => t<'v>

    remove m x returns a map containing the same bindings as m, except for x which is unbound in the returned map.

    removeMany

    RESCRIPT
    let removeMany: (t<'v>, array<key>) => t<'v>

    set

    RESCRIPT
    let set: (t<'v>, key, 'v) => t<'v>

    set(m, x, y) returns a map containing the same bindings as m, plus a binding of x to y. If x was already bound in m, its previous binding disappears.

    updateU

    Deprecated

    Use update instead

    RESCRIPT
    let updateU: (t<'v>, key, option<'v> => option<'v>) => t<'v>

    update

    RESCRIPT
    let update: (t<'v>, key, option<'v> => option<'v>) => t<'v>

    mergeU

    Deprecated

    Use merge instead

    RESCRIPT
    let mergeU: ( t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>, ) => t<'c>

    merge

    RESCRIPT
    let merge: ( t<'v>, t<'v2>, (key, option<'v>, option<'v2>) => option<'c>, ) => t<'c>

    merge(m1, m2, f) computes a map whose keys is a subset of keys of m1 and of m2. The presence of each such binding, and the corresponding value, is determined with the function f.

    mergeMany

    RESCRIPT
    let mergeMany: (t<'v>, array<(key, 'v)>) => t<'v>

    keepU

    Deprecated

    Use keep instead

    RESCRIPT
    let keepU: (t<'v>, (key, 'v) => bool) => t<'v>

    keep

    RESCRIPT
    let keep: (t<'v>, (key, 'v) => bool) => t<'v>

    keep(m, p) returns the map with all the bindings in m that satisfy predicate p.

    partitionU

    Deprecated

    Use partition instead

    RESCRIPT
    let partitionU: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)

    partition

    RESCRIPT
    let partition: (t<'v>, (key, 'v) => bool) => (t<'v>, t<'v>)

    partition(m, p) returns a pair of maps (m1, m2), where m1 contains all the bindings of s that satisfy the predicate p, and m2 is the map with all the bindings of s that do not satisfy p.

    split

    RESCRIPT
    let split: (key, t<'v>) => (t<'v>, option<'v>, t<'v>)

    split(x, m) returns a triple (l, data, r), where l is the map with all the bindings of m whose key is strictly less than x; r is the map with all the bindings of m whose key is strictly greater than x; data is None if m contains no binding for x, or Some(v) if m binds v to x.

    mapU

    Deprecated

    Use map instead

    RESCRIPT
    let mapU: (t<'v>, 'v => 'v2) => t<'v2>

    map

    RESCRIPT
    let map: (t<'v>, 'v => 'v2) => t<'v2>

    map(m, f) returns a map with same domain as m, where the associated value a of all bindings of m has been replaced by the result of the application of f to a. The bindings are passed to f in increasing order with respect to the ordering over the type of the keys.

    mapWithKeyU

    Deprecated

    Use mapWithKey instead

    RESCRIPT
    let mapWithKeyU: (t<'v>, (key, 'v) => 'v2) => t<'v2>

    mapWithKey

    RESCRIPT
    let mapWithKey: (t<'v>, (key, 'v) => 'v2) => t<'v2>
    Types and values
    • t
      key
    • t
      t
    • v
      empty
    • v
      isEmpty
    • v
      has
    • v
      cmpU
      D
    • v
      cmp
    • v
      eqU
      D
    • v
      eq
    • v
      findFirstByU
      D
    • v
      findFirstBy
    • v
      forEachU
      D
    • v
      forEach
    • v
      reduceU
      D
    • v
      reduce
    • v
      everyU
      D
    • v
      every
    • v
      someU
      D
    • v
      some
    • v
      size
    • v
      toList
    • v
      toArray
    • v
      fromArray
    • v
      keysToArray
    • v
      valuesToArray
    • v
      minKey
    • v
      minKeyUndefined
    • v
      maxKey
    • v
      maxKeyUndefined
    • v
      minimum
    • v
      minUndefined
    • v
      maximum
    • v
      maxUndefined
    • v
      get
    • v
      getUndefined
    • v
      getWithDefault
    • v
      getExn
    • v
      checkInvariantInternal
    • v
      remove
    • v
      removeMany
    • v
      set
    • v
      updateU
      D
    • v
      update
    • v
      mergeU
      D
    • v
      merge
    • v
      mergeMany
    • v
      keepU
      D
    • v
      keep
    • v
      partitionU
      D
    • v
      partition
    • v
      split
    • v
      mapU
      D
    • v
      map
    • v
      mapWithKeyU
      D
    • v
      mapWithKey

    © 2024 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on