Module Base

This module is the toplevel of the Base library, it is what you get when you do open Base.

The recommended way to use Base is to build with -open Base. Files compiled this way will have the environment described in this file as initial environment.

module Applicative : sig ... end
module Applicative_intf : sig ... end

Applicatives model computations in which values computed by subcomputations cannot affect what subsequent computations will take place. Relative to monads, this restriction takes power away from the user of the interface and gives it to the implementation. In particular, because the structure of the entire computation is known, one can augment its definition with some description of that structure.

module Array : sig ... end
module Avltree : sig ... end

A low-level, mutable AVL tree.

module Backtrace : sig ... end

Dealing with stack backtraces.

module Binary_searchable : sig ... end

See Binary_searchable_intf.

module Binary_searchable_intf : sig ... end

Module types for a binary_search function for a sequence, and functors for building binary_search functions.

module Blit : sig ... end

See Blit_intf for documentation.

module Blit_intf : sig ... end

Standard type for blit functions, and reusable code for validating blit arguments.

module Bool : sig ... end
module Buffer : sig ... end
module Bytes : sig ... end

OCaml's byte sequence type, semantically similar to a char array, but taking less space in memory.

module Char : sig ... end

Character operations.

module Commutative_group : sig ... end

A signature for a commutative group (in the group-theory sense).

module Comparable : sig ... end
module Comparable_intf : sig ... end
module Comparator : sig ... end

A type-indexed value that allows one to compare (and for generating error messages, serialize) values of the type in question.

module Comparisons : sig ... end

Interfaces for infix comparison operators and comparison functions.

module Container : sig ... end
module Container_intf : sig ... end

This file has generic signatures for container data structures, with standard functions (iter, fold, exists, for_all, ...) that one would expect to find in any container. The idea is to include Container.S0 or Container.S1 in the signature for every container-like data structure (Array, List, String, ...) to ensure a consistent interface.

module Either : sig ... end
module Either_intf : sig ... end

Many functions in Either focus on just one constructor. The Focused signature abstracts over which constructor is the focus. To use these functions, use the First or Second modules in S.

module Equal : sig ... end

This module defines signatures that are to be included in other signatures to ensure a consistent interface to equal functions. There is a signature (S, S1, S2, S3) for each arity of type. Usage looks like:

module Error : sig ... end

A lazy string, implemented with Info, but intended specifically for error messages.

module Exn : sig ... end

sexp_of_t uses a global table of sexp converters. To register a converter for a new exception, add [@@deriving_inline sexp][@@@end] to its definition. If no suitable converter is found, the standard converter in Printexc will be used to generate an atomic S-expression.

module Field : sig ... end

OCaml record field.

module Float : sig ... end

Floating-point representation and utilities.

module Floatable : sig ... end
module Fn : sig ... end

various combinators for functions

module Hash : sig ... end
module Hash_intf : sig ... end

Hash_intf.S is the interface which a hash-function must support

module Hash_set : sig ... end
module Hash_set_intf : sig ... end
module Hasher : sig ... end

Signatures required of types which can be used in [@@deriving_inline hash][@@@end].

module Hashtbl : sig ... end
module Hashtbl_intf : sig ... end
module Heap_block : sig ... end

A heap block is a value that is guaranteed to live on the OCaml heap, and is hence guaranteed to be usable with finalization or in a weak pointer. It is an abstract type so we can use the type system to guarantee that the values we put in weak pointers and use with finalizers are heap blocks.

module Identifiable : sig ... end

A signature combining functionality that is commonly used for types that are intended to act as names or identifiers.

module Indexed_container : sig ... end
module Info : sig ... end
module Info_intf : sig ... end

Info is a library for lazily constructing human-readable information as a string or sexp, with a primary use being error messages. Using Info is often preferable to sprintf or manually constructing strings because you don't have to eagerly construct the string --- you only need to pay when you actually want to display the info. which for many applications is rare. Using Info is also better than creating custom exceptions because you have more control over the format.

module Int : sig ... end

OCaml's native integer type.

module Int32 : sig ... end

An int of exactly 32 bits, regardless of the machine.

module Int63 : sig ... end

63-bit integers.

module Int64 : sig ... end
module Int_intf : sig ... end
module Intable : sig ... end
module Invariant : sig ... end
module Lazy : sig ... end

This file is a modified version of lazy.mli from the OCaml distribution.

module List : sig ... end

List operations.

module Map : sig ... end
module Map_intf : sig ... end

See map.mli for comments.

module Maybe_bound : sig ... end
module Monad : sig ... end
module Nativeint : sig ... end
module Obj_array : sig ... end

An array of Caml.Obj.ts.

module Option : sig ... end
module Or_error : sig ... end

Type for tracking errors in an Error.t. This is a specialization of the Result type, where the Error constructor carries an Error.t.

module Ordered_collection_common : sig ... end
module Ordering : sig ... end

Ordering is intended to make code that matches on the result of a comparison more concise and easier to read. For example, instead of writing:

module Poly : sig ... end
module Polymorphic_compare : sig ... end
module Popcount : sig ... end

This module exposes popcount functions for the various integer types. Functions are exposed in their respective modules.

module Pretty_printer : sig ... end

A list of pretty printers for various types, for use in toplevels.

module Printf : sig ... end
module Linked_queue : sig ... end

This module is a wrapper around OCaml's standard Queue module that follows Base idioms and adds some functions. See Queue_intf for documentation of standard queue functions.

module Queue_intf : sig ... end

An interface for queues that follows Base's conventions, as opposed to OCaml's standard Queue module.

module Random : sig ... end

Pseudo-random number generation.

module Ref : sig ... end

Module for the type ref

module Result : sig ... end

Result is often used to handle error messages.

module Sequence : sig ... end

A sequence of elements that can be produced one at a time, on demand, normally with no sharing.

module Set : sig ... end
module Set_intf : sig ... end

See set.mli for comments.

module Sexpable : sig ... end

New code should use the @@deriving_inline sexp@@@end syntax directly. These module types (S, S1, S2, and S3) are exported for backwards compatibility only. *

module Sign : sig ... end

A simple type for representing the sign of a numeric value.

module Source_code_position : sig ... end

One typically obtains a Source_code_position.t using a [%here] expression, which is implemented by the ppx_here preprocessor.

module Staged : sig ... end

A type for making staging explicit in the type of a function. For example, you might want to have a function that creates a function for allocating unique identifiers. Rather than using the type:

module String : sig ... end

An extension of the standard StringLabels. If you open Base, you'll get these in the String module.

module Stringable : sig ... end
module String_dict : sig ... end

Efficient static string dictionaries. By static, we mean that new key-value pairs cannot be added after the dictionary is created.

module Sys : sig ... end

Cross-platform system configuration values.

module T : sig ... end
module Type_equal : sig ... end

For representing type equalities otherwise not known by the type-checker.

module Unit : sig ... end

Module for the type unit

module Uchar : sig ... end

Unicode character operations.

module Validate : sig ... end

A module for organizing validations of data structures. Allows standardized ways of checking for conditions, and keeps track of the location of errors by keeping a path to each error found. Thus, if you were validating the following datastructure:

module Variant : sig ... end

OCaml variant type.

module With_return : sig ... end

with_return f allows for something like the return statement in C within f. There are three ways f can terminate:

module Word_size : sig ... end

For determining the word size that the program is using.

module type T : sig ... end
module type T1 : sig ... end
module type T2 : sig ... end
module type T3 : sig ... end
module Sexp : sig ... end
module Export : sig ... end
include Export
type 'a array = 'a Array.t
val compare_array : a. ('a ‑> 'a ‑> int) ‑> 'a array ‑> 'a array ‑> int
val array_of_sexp : a. (Sexp.t ‑> 'a) ‑> Sexp.t ‑> 'a array
val sexp_of_array : a. ('a ‑> Sexp.t) ‑> 'a array ‑> Sexp.t
type bool = Bool.t
val compare_bool : bool ‑> bool ‑> int
val hash_fold_bool : Hash.state ‑> bool ‑> Hash.state
val hash_bool : bool ‑> Hash.hash_value
val bool_of_sexp : Sexp.t ‑> bool
val sexp_of_bool : bool ‑> Sexp.t
type char = Char.t
val compare_char : char ‑> char ‑> int
val hash_fold_char : Hash.state ‑> char ‑> Hash.state
val hash_char : char ‑> Hash.hash_value
val char_of_sexp : Sexp.t ‑> char
val sexp_of_char : char ‑> Sexp.t
type exn = Exn.t
val sexp_of_exn : exn ‑> Sexp.t
type float = Float.t
val compare_float : float ‑> float ‑> int
val hash_fold_float : Hash.state ‑> float ‑> Hash.state
val hash_float : float ‑> Hash.hash_value
val float_of_sexp : Sexp.t ‑> float
val sexp_of_float : float ‑> Sexp.t
type int = Int.t
val compare_int : int ‑> int ‑> int
val hash_fold_int : Hash.state ‑> int ‑> Hash.state
val hash_int : int ‑> Hash.hash_value
val int_of_sexp : Sexp.t ‑> int
val sexp_of_int : int ‑> Sexp.t
type int32 = Int32.t
val compare_int32 : int32 ‑> int32 ‑> int
val hash_fold_int32 : Hash.state ‑> int32 ‑> Hash.state
val hash_int32 : int32 ‑> Hash.hash_value
val int32_of_sexp : Sexp.t ‑> int32
val sexp_of_int32 : int32 ‑> Sexp.t
type int64 = Int64.t
val compare_int64 : int64 ‑> int64 ‑> int
val hash_fold_int64 : Hash.state ‑> int64 ‑> Hash.state
val hash_int64 : int64 ‑> Hash.hash_value
val int64_of_sexp : Sexp.t ‑> int64
val sexp_of_int64 : int64 ‑> Sexp.t
type 'a list = 'a List.t
val compare_list : a. ('a ‑> 'a ‑> int) ‑> 'a list ‑> 'a list ‑> int
val hash_fold_list : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a list ‑> Hash.state
val list_of_sexp : a. (Sexp.t ‑> 'a) ‑> Sexp.t ‑> 'a list
val sexp_of_list : a. ('a ‑> Sexp.t) ‑> 'a list ‑> Sexp.t
type nativeint = Nativeint.t
val compare_nativeint : nativeint ‑> nativeint ‑> int
val hash_fold_nativeint : Hash.state ‑> nativeint ‑> Hash.state
val hash_nativeint : nativeint ‑> Hash.hash_value
val nativeint_of_sexp : Sexp.t ‑> nativeint
val sexp_of_nativeint : nativeint ‑> Sexp.t
type 'a option = 'a Option.t
val compare_option : a. ('a ‑> 'a ‑> int) ‑> 'a option ‑> 'a option ‑> int
val hash_fold_option : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a option ‑> Hash.state
val option_of_sexp : a. (Sexp.t ‑> 'a) ‑> Sexp.t ‑> 'a option
val sexp_of_option : a. ('a ‑> Sexp.t) ‑> 'a option ‑> Sexp.t
type 'a ref = 'a Ref.t
val compare_ref : a. ('a ‑> 'a ‑> int) ‑> 'a ref ‑> 'a ref ‑> int
val ref_of_sexp : a. (Sexp.t ‑> 'a) ‑> Sexp.t ‑> 'a ref
val sexp_of_ref : a. ('a ‑> Sexp.t) ‑> 'a ref ‑> Sexp.t
type string = String.t
val compare_string : string ‑> string ‑> int
val hash_fold_string : Hash.state ‑> string ‑> Hash.state
val hash_string : string ‑> Hash.hash_value
val string_of_sexp : Sexp.t ‑> string
val sexp_of_string : string ‑> Sexp.t
type bytes = Bytes.t
val compare_bytes : bytes ‑> bytes ‑> int
val bytes_of_sexp : Sexp.t ‑> bytes
val sexp_of_bytes : bytes ‑> Sexp.t
type unit = Unit.t
val compare_unit : unit ‑> unit ‑> int
val hash_fold_unit : Hash.state ‑> unit ‑> Hash.state
val hash_unit : unit ‑> Hash.hash_value
val unit_of_sexp : Sexp.t ‑> unit
val sexp_of_unit : unit ‑> Sexp.t
type ('a, 'b, 'c) format = ('a'b'c) Pervasives.format

Format stuff

type ('a, 'b, 'c, 'd) format4 = ('a'b'c'd) Pervasives.format4
type ('a, 'b, 'c, 'd, 'e, 'f) format6 = ('a'b'c'd'e'f) Pervasives.format6

Sexp

Exporting the ad-hoc types that are recognized by ppx_sexp_* converters. sexp_array, sexp_list, and sexp_option allow a record field to be absent when converting from a sexp, and if absent, the field will take a default value of the appropriate type:

        sexp_array   [||]
        sexp_bool    false
        sexp_list    []
        sexp_option  None

sexp_opaque causes the conversion to sexp to produce the atom <opaque>.

For more documentation, see sexplib/README.md.

type 'a sexp_array = 'a array
type 'a sexp_list = 'a list
type 'a sexp_opaque = 'a
type 'a sexp_option = 'a option

List operators

include List.Infix
val (@) : 'a Base__List.t ‑> 'a Base__List.t ‑> 'a Base__List.t

Int operators and comparisons

include Int.O

A sub-module designed to be opened to make working with ints more convenient.

include Int_intf.Operators_unbounded
type t
val (+) : t ‑> t ‑> t
val (-) : t ‑> t ‑> t
val (*) : t ‑> t ‑> t
val (/) : t ‑> t ‑> t
val (~-) : t ‑> t
include Comparisons.Infix with type t := t
type t
val (>=) : t ‑> t ‑> bool
val (<=) : t ‑> t ‑> bool
val (=) : t ‑> t ‑> bool
val (>) : t ‑> t ‑> bool
val (<) : t ‑> t ‑> bool
val (<>) : t ‑> t ‑> bool
val abs : t ‑> t
val neg : t ‑> t
val zero : t
val (%) : t ‑> t ‑> t
val (/%) : t ‑> t ‑> t
val (//) : t ‑> t ‑> float
val (land) : t ‑> t ‑> t
val (lor) : t ‑> t ‑> t
val (lxor) : t ‑> t ‑> t
val (lnot) : t ‑> t
val (lsl) : t ‑> int ‑> t
val (asr) : t ‑> int ‑> t
val (lsr) : t ‑> int ‑> t
include Base__.Import.Int_replace_polymorphic_compare
val (<) : int ‑> int ‑> bool
val (<=) : int ‑> int ‑> bool
val (<>) : int ‑> int ‑> bool
val (=) : int ‑> int ‑> bool
val (>) : int ‑> int ‑> bool
val (>=) : int ‑> int ‑> bool
val ascending : int ‑> int ‑> int
val descending : int ‑> int ‑> int
val compare : int ‑> int ‑> int
val equal : int ‑> int ‑> bool
val max : int ‑> int ‑> int
val min : int ‑> int ‑> int

Float operators

include Float.O_dot

Similar to O, except that operators are suffixed with a dot, allowing one to have both int and float operators in scope simultaneously.

Similar to O, except that operators are suffixed with a dot, allowing one to have both int and float operators in scope simultaneously.

val (+.) : Float.t ‑> Float.t ‑> Float.t
val (-.) : Float.t ‑> Float.t ‑> Float.t
val (*.) : Float.t ‑> Float.t ‑> Float.t
val (/.) : Float.t ‑> Float.t ‑> Float.t
val (**.) : Float.t ‑> Float.t ‑> Float.t
val (~-.) : Float.t ‑> Float.t
external (|>) : 'a ‑> ('a ‑> 'b) ‑> 'b = "%revapply"

Reverse application operator. x |> g |> f is equivalent to f (g (x)).

external (@@) : ('a ‑> 'b) ‑> 'a ‑> 'b = "%apply"

Application operator. g @@ f @@ x is equivalent to g (f (x)).

external (&&) : bool ‑> bool ‑> bool = "%sequand"

Boolean operations

external (||) : bool ‑> bool ‑> bool = "%sequor"
external not : bool ‑> bool = "%boolnot"
external ignore : _ ‑> unit = "%ignore"
val (^) : String.t ‑> String.t ‑> String.t

Common string operations

external (!) : 'a ref ‑> 'a = "%field0"

Reference operations

external ref : 'a ‑> 'a ref = "%makemutable"
external (:=) : 'a ref ‑> 'a ‑> unit = "%setfield0"
val fst : ('a * 'b) ‑> 'a

Pair operations

val snd : ('a * 'b) ‑> 'b
val failwith : string ‑> 'a

Exceptions stuff

val invalid_arg : string ‑> 'a
val raise : exn ‑> 'a
val raise_s : Sexp.t ‑> 'a
val phys_equal : 'a ‑> 'a ‑> bool

Misc

external force : 'a Lazy.t ‑> 'a = "%lazy_force"
module Continue_or_stop = Container_intf.Export.Continue_or_stop

Continue_or_stop.t is used by the f argument to fold_until in order to indicate whether folding should continue, or stop early.

module Finished_or_stopped_early = Container_intf.Export.Finished_or_stopped_early

Finished_or_stopped_early.t is returned by fold_until to indicate whether f requested the fold stop, or if the fold completed.

module Not_exposed_properly : sig ... end