package base

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'key key

The type of keys. This will be 'key for polymorphic dictionaries, or some fixed type for dictionaries with monomorphic keys.

type ('key, 'data, 'phantom) t

Dictionaries. Their keys have type 'key key. Each key's associated value has type 'data. The dictionary may be distinguished by a 'phantom type.

type ('fn, 'key, 'data, 'phantom) creator

The type of creator functions 'fn that operate on ('key, 'data, 'phantom) t. May take extra arguments before 'fn, such as a comparison function.

val create : (unit -> ('key, 'data, 'phantom) t, 'key, 'data, 'phantom) creator

Creates a new empty dictionary.

val of_alist : (('key key * 'data) list -> [ `Ok of ('key, 'data, 'phantom) t | `Duplicate_key of 'key key ], 'key, 'data, 'phantom) creator

Dictionary containing the given key/value pairs. Fails if there are duplicate keys.

val of_alist_report_all_dups : (('key key * 'data) list -> [ `Ok of ('key, 'data, 'phantom) t | `Duplicate_keys of 'key key list ], 'key, 'data, 'phantom) creator

Like of_alist. On failure, provides all duplicate keys instead of a single representative.

val of_alist_or_error : (('key key * 'data) list -> ('key, 'data, 'phantom) t Or_error.t, 'key, 'data, 'phantom) creator

Like of_alist. Returns a Result.t.

val of_alist_exn : (('key key * 'data) list -> ('key, 'data, 'phantom) t, 'key, 'data, 'phantom) creator

Like of_alist. Raises on duplicates.

val of_alist_multi : (('key key * 'data) list -> ('key, 'data list, 'phantom) t, 'key, 'data list, 'phantom) creator

Produces a dictionary mapping each key to a list of associated values.

val create_mapped : (get_key:('a -> 'key key) -> get_data:('a -> 'data) -> 'a list -> [ `Ok of ('key, 'data, 'phantom) t | `Duplicate_keys of 'key key list ], 'key, 'data, 'phantom) creator

Like of_alist. Consume a list of elements for which key/value pairs can be computed.

val create_with_key : (get_key:('data -> 'key key) -> 'data list -> [ `Ok of ('key, 'data, 'phantom) t | `Duplicate_keys of 'key key list ], 'key, 'data, 'phantom) creator

Like of_alist. Consume values for which keys can be computed.

val create_with_key_or_error : (get_key:('data -> 'key key) -> 'data list -> ('key, 'data, 'phantom) t Or_error.t, 'key, 'data, 'phantom) creator

Like of_alist_or_error. Consume values for which keys can be computed.

val create_with_key_exn : (get_key:('data -> 'key key) -> 'data list -> ('key, 'data, 'phantom) t, 'key, 'data, 'phantom) creator

Like of_alist_exn. Consume values for which keys can be computed.

val group : (get_key:('a -> 'key key) -> get_data:('a -> 'data) -> combine:('data -> 'data -> 'data) -> 'a list -> ('key, 'data, 'phantom) t, 'key, 'data, 'phantom) creator

Like create_mapped. Multiple values for a key are combined rather than producing an error.

OCaml

Innovation. Community. Security.