Module Core_kernel.Total_map

A map that includes an entry for every possible value of the key type.

This is intended to be used on 'key types where there is a full enumeration of the type. In the common use case, 'key will be a simple variant type with [@@deriving compare, enumerate]. For example:

      module Arrow_key = struct
        module T = struct
          type t =
            | Up
            | Down
            | Left
            | Right
          [@@deriving sexp, bin_io, compare, enumerate]
        end
        include T
        module Total_map = Total_map.Make (T)
      end

In such a case, a t is semantically equivalent to a pure function from 'key to 'value. The differences are that it is serializable and that mapping or changing a t will produce a t using the same amount of space as the original.

However, in theory you could also modify the comparison function and enumeration, so long as the enumeration contains at least one representative of each equivalence class determined by the comparison function.

type ('key, 'a, 'cmp, 'enum) t = private ('key'a'cmpMap.t
val to_map : ('key'a'cmp_t ‑> ('key'a'cmpMap.t

Many of the functions below have types reflecting the fact that the maps are total (e.g., find does not return an option). The fact that they won't raise exceptions relies on the enumeration passed to Make being complete.

val map : ('key'a'c'et ‑> f:('a ‑> 'b) ‑> ('key'b'c'et
val mapi : ('key'a'c'et ‑> f:(key:'key ‑> data:'a ‑> 'b) ‑> ('key'b'c'et
val map2 : ('key'a'cmp'enumt ‑> ('key'b'cmp'enumt ‑> f:('a ‑> 'b ‑> 'c) ‑> ('key'c'cmp'enumt
val iter_keys : ('key___t ‑> f:('key ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unit
val iter : (_'a__t ‑> f:('a ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unit
val iteri : ('key'a__t ‑> f:(key:'key ‑> data:'a ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unit
val iter2 : ('key'a'cmp'enumt ‑> ('key'b'cmp'enumt ‑> f:(key:'key ‑> 'a ‑> 'b ‑> Core_kernel__.Import.unit) ‑> Core_kernel__.Import.unit
val set : ('key'a'cmp'enumt ‑> 'key ‑> 'a ‑> ('key'a'cmp'enumt
val to_alist : ?⁠key_order:[ `Increasing | `Decreasing ] ‑> ('key'a__t ‑> ('key * 'a) Core_kernel__.Import.list
val find : ('key'a__t ‑> 'key ‑> 'a
val change : ('key'a'c'et ‑> 'key ‑> f:('a ‑> 'a) ‑> ('key'a'c'et
val data : (_'a__t ‑> 'a Core_kernel__.Import.list
val for_all : (_'a__t ‑> f:('a ‑> Core_kernel__.Import.bool) ‑> Core_kernel__.Import.bool
module Sequence : functor (A : Core_kernel__.Std_internal.Applicative) -> sig ... end

Sequence a total map of computations in order of their keys resulting in computation of the total map of results.

The only reason that the Applicative interface isn't included here is that we don't have an Applicative.S3.

module type Key : sig ... end
module type S : sig ... end
module Make : functor (Key : Key) -> S with module Key = Key
module Make_using_comparator : functor (Key : sig ... end) -> S with module Key = Key with type comparator_witness = Key.comparator_witness