Module BaseSource
This module is the toplevel of the Base library; it's what you get when you write open Base.
The goal of Base is both to be a more complete standard library, with richer APIs, and to be more consistent in its design. For instance, in the standard library some things have modules and others don't; in Base, everything is a module.
Base extends some modules and data structures from the standard library, like Array, Buffer, Bytes, Char, Hashtbl, Int32, Int64, Lazy, List, Map, Nativeint, Printf, Random, Set, String, Sys, and Uchar. One key difference is that Base doesn't use exceptions as much as the standard library and instead makes heavy use of the Result type, as in:
type ('a, 'b) result =
| Ok of 'a
| Error of 'bBase also adds entirely new modules, most notably:
Comparable,Comparator, andComparisonsin lieu of polymorphic compare.Container, which provides a consistent interface across container-like data structures (arrays, lists, strings).Result,Error, andOr_error, supporting the or-error pattern.
Functions for performing binary searches over ordered sequences given length and get functions.
Boolean type extended to be enumerable, hashable, sexpable, comparable, and stringable.
Interfaces for infix comparison operators and comparison functions.
A value of type 'a Dynamic.t is a dynamically scoped variable of type 'a.
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:
The Format.formatter type from OCaml's standard library, exported here for convenience and compatibility with other libraries.
Signatures required of types which can be used in [@@deriving hash].
This module implements derived integer operations (e.g., modulo, rounding to multiples) based on other basic operations.
This module defines signatures that are to be included in other signatures to ensure a consistent interface to invariant-style functions. There is a signature (S, S1, S2, S3) for each arity of type. Usage looks like:
A value of type 'a Lazy.t is a deferred computation, called a suspension, that has a result of type 'a.
Immutable, singly-linked lists, giving fast access to the front of the list, and slow (i.e., O(n)) access to the back of the list. The comparison functions on lists are lexicographic.
Used for specifying a bound (either upper or lower) as inclusive, exclusive, or unbounded.
An uninhabited type. This is useful when interfaces require that a type be specified, but the implementer knows this type will not be used in their implementation of the interface.
Versions of Stdlib.Obj functions that work with modes. Note it is never safe to magic a local value to global.
The option type indicates whether a meaningful value is present. It is frequently used to represent success or failure, using None for failure. To be more descriptive about why a function failed, see the Or_error module.
'a Option_array.t is a compact representation of 'a option array: it avoids allocating heap objects representing Some x, usually representing them with x instead. It uses a special representation for None that's guaranteed to never collide with any representation of Some x.
Type for tracking errors in an Error.t. This is a specialization of the Result type, where the Error constructor carries an Error.t.
'a or_null, or the unboxed option type, represents a value of type 'a or its absence. Similar to option, it has two constructors, Null and This a.
Functions for ordered collections.
Ordering is intended to make code that matches on the result of a comparison more concise and easier to read.
A module containing the ad-hoc polymorphic comparison functions. Useful when you want to use polymorphic compare in some small scope of a file within which polymorphic compare has been hidden
A value of type 'a Portable_lazy.t is a deferred computation that has a result of type 'a.
A list of pretty printers for various types, for use in toplevels.
This module is a Base-style wrapper around OCaml's standard Queue module.
A 'a t represents a non-empty list, as evidenced by the fact that there is no [] variant. The sexp representation is as a regular list (i.e., the same as the Stable.V3 module below).
Module for the type ref, mutable indirection cells r containing a value of type 'a, accessed with !r and set by r := a.
A sequence of elements that can be produced one at a time, on demand, normally with no sharing.
Provides functors for making modules sexpable when you want the sexp representation of one type to be the same as that for some other isomorphic type.
An extension to Sign with a Nan constructor, for representing the sign of float-like numeric values.
One typically obtains a Source_code_position.t using a [%here] expression, which is implemented by the ppx_here preprocessor.
Provides type-specific conversion functions to and from string.
This module defines various abstract interfaces that are convenient when one needs a module that matches a bare signature with just a type. This sometimes occurs in functor arguments and in interfaces.
This module provides a wrapper that can be used to simulate having toplevel items of non-value layout in modules. For example,
Same semantics as 'a Array.t, except it's guaranteed that the representation array is not tagged with Double_array_tag, the tag for float arrays.
First-class representative of an individual variant in a variant type, used in [@@deriving variants].
with_return f allows for something like the return statement in C within f.
include module type of struct include Base.Export end
include sig ... end
val sexp_of_array__stack :
'a. ('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Array.t @ once ->
Sexplib0.Sexp.t @ onceval array_sexp_grammar :
'a. 'a Sexplib0.Sexp_grammar.t ->
'a Array.t Sexplib0.Sexp_grammar.t @@ portableinclude sig ... end
include sig ... end
include sig ... end
include sig ... end
val hash_fold_float :
Ppx_hash_lib.Std.Hash.state ->
Base.float ->
Ppx_hash_lib.Std.Hash.stateinclude sig ... end
include sig ... end
val hash_fold_iarray :
'a. (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'a Iarray.t ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_iarray__stack :
('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Iarray.t @ once ->
Sexplib0.Sexp.t @ onceval iarray_sexp_grammar :
'a. 'a Sexplib0.Sexp_grammar.t ->
'a Iarray.t Sexplib0.Sexp_grammar.t @@ portableinclude sig ... end
include sig ... end
val hash_fold_int32 :
Ppx_hash_lib.Std.Hash.state ->
Base.int32 ->
Ppx_hash_lib.Std.Hash.stateinclude sig ... end
val hash_fold_int64 :
Ppx_hash_lib.Std.Hash.state ->
Base.int64 ->
Ppx_hash_lib.Std.Hash.stateinclude sig ... end
val hash_fold_list :
'a. (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'a Base.list ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_list__stack :
'a. ('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Base.list @ once ->
Sexplib0.Sexp.t @ onceval list_sexp_grammar :
'a. 'a Sexplib0.Sexp_grammar.t ->
'a Base.list Sexplib0.Sexp_grammar.tinclude sig ... end
val hash_fold_nativeint :
Ppx_hash_lib.Std.Hash.state ->
Base.nativeint ->
Ppx_hash_lib.Std.Hash.stateinclude sig ... end
val compare_option__local :
'a. ('a @ once -> 'a @ once -> Base.int) ->
'a Base.option @ once ->
'a Base.option @ once ->
Base.intval compare_option :
'a. ('a -> 'a -> Base.int) ->
'a Base.option ->
'a Base.option ->
Base.intval equal_option__local :
'a. ('a @ once -> 'a @ once -> Base.bool) ->
'a Base.option @ once ->
'a Base.option @ once ->
Base.boolval equal_option :
'a. ('a -> 'a -> Base.bool) ->
'a Base.option ->
'a Base.option ->
Base.boolval hash_fold_option :
'a. (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'a Base.option ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_option__stack :
'a. ('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Base.option @ once ->
Sexplib0.Sexp.t @ onceval option_sexp_grammar :
'a. 'a Sexplib0.Sexp_grammar.t ->
'a Base.option Sexplib0.Sexp_grammar.tinclude sig ... end
val compare_result__local :
'a 'b. ('a @ once -> 'a @ once -> Base.int) ->
('b @ once -> 'b @ once -> Base.int) ->
('a, 'b) Base.result @ once ->
('a, 'b) Base.result @ once ->
Base.intval compare_result :
'a 'b. ('a -> 'a -> Base.int) ->
('b -> 'b -> Base.int) ->
('a, 'b) Base.result ->
('a, 'b) Base.result ->
Base.intval equal_result__local :
'a 'b. ('a @ once -> 'a @ once -> Base.bool) ->
('b @ once -> 'b @ once -> Base.bool) ->
('a, 'b) Base.result @ once ->
('a, 'b) Base.result @ once ->
Base.boolval equal_result :
'a 'b. ('a -> 'a -> Base.bool) ->
('b -> 'b -> Base.bool) ->
('a, 'b) Base.result ->
('a, 'b) Base.result ->
Base.boolval globalize_result :
'a 'b. ('a @ once -> 'a) ->
('b @ once -> 'b) ->
('a, 'b) Base.result @ once ->
('a, 'b) Base.resultval hash_fold_result :
'a 'b. (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) ->
(Ppx_hash_lib.Std.Hash.state -> 'b -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('a, 'b) Base.result ->
Ppx_hash_lib.Std.Hash.stateval result_of_sexp :
'a 'b. (Sexplib0.Sexp.t -> 'a) ->
(Sexplib0.Sexp.t -> 'b) ->
Sexplib0.Sexp.t ->
('a, 'b) Base.resultval sexp_of_result :
'a 'b. ('a -> Sexplib0.Sexp.t) ->
('b -> Sexplib0.Sexp.t) ->
('a, 'b) Base.result ->
Sexplib0.Sexp.tval sexp_of_result__stack :
'a 'b. ('a @ once -> Sexplib0.Sexp.t @ once) ->
('b @ once -> Sexplib0.Sexp.t @ once) ->
('a, 'b) Base.result @ once ->
Sexplib0.Sexp.t @ onceval result_sexp_grammar :
'a 'b. 'a Sexplib0.Sexp_grammar.t ->
'b Sexplib0.Sexp_grammar.t ->
('a, 'b) Base.result Sexplib0.Sexp_grammar.tinclude sig ... end
val sexp_of_ref__stack :
'a. ('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Base.ref @ once ->
Sexplib0.Sexp.t @ onceinclude sig ... end
val hash_fold_string :
Ppx_hash_lib.Std.Hash.state ->
Base.string ->
Ppx_hash_lib.Std.Hash.stateinclude sig ... end
include sig ... end
Format stuff
List operators
include module type of struct include List.Infix end
Iarray operators
include module type of struct include Iarray.O end
val (.:()) : 'a. 'a Basement.Stdlib_iarray_labels.t -> int -> 'aAn alias for get.
Int operators and comparisons
Float operators
Reverse application operator. x |> g |> f is equivalent to f (g (x)).
Application operator. g @@ f @@ x is equivalent to g (f (x)).
Boolean operations
Reference operations
Pair operations
Exceptions stuff
Misc
include sig ... end
val compare_or_null__local :
'a. ('a @ once -> 'a @ once -> Base.int) ->
'a Base.or_null @ once ->
'a Base.or_null @ once ->
Base.intval compare_or_null :
'a. ('a -> 'a -> Base.int) ->
'a Base.or_null ->
'a Base.or_null ->
Base.intval equal_or_null__local :
'a. ('a @ once -> 'a @ once -> Base.bool) ->
'a Base.or_null @ once ->
'a Base.or_null @ once ->
Base.boolval equal_or_null :
'a. ('a -> 'a -> Base.bool) ->
'a Base.or_null ->
'a Base.or_null ->
Base.boolval hash_fold_or_null :
'a. (Ppx_hash_lib.Std.Hash.state -> 'a -> Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
'a Base.or_null ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_or_null__stack :
'a. ('a @ once -> Sexplib0.Sexp.t @ once) ->
'a Base.or_null @ once ->
Sexplib0.Sexp.t @ onceContinue_or_stop.t is used by the f argument to fold_until in order to indicate whether folding should continue, or stop early.
include module type of struct include Modes.Export end
include sig ... end
val compare_global :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> int) ->
('a : value_or_null) Base.global ->
('a : value_or_null) Base.global ->
intval compare_global__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
int) ->
('a : value_or_null) Base.global @ local ->
('a : value_or_null) Base.global @ local ->
intval equal_global :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> bool) ->
('a : value_or_null) Base.global ->
('a : value_or_null) Base.global ->
boolval equal_global__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
bool) ->
('a : value_or_null) Base.global @ local ->
('a : value_or_null) Base.global @ local ->
boolval hash_fold_global :
('a : value_or_null). (Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) ->
Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) Base.global ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_global :
('a : value_or_null). (('a : value_or_null) -> Sexplib0.Sexp.t) ->
('a : value_or_null) Base.global ->
Sexplib0.Sexp.tval sexp_of_global__stack :
('a : value_or_null). (('a : value_or_null) @ local ->
Sexplib0.Sexp.t @ local) ->
('a : value_or_null) Base.global @ local ->
Sexplib0.Sexp.t @ localval global_of_sexp :
('a : value_or_null). (Sexplib0.Sexp.t -> ('a : value_or_null)) ->
Sexplib0.Sexp.t ->
('a : value_or_null) Base.globalval global_sexp_grammar :
('a : value_or_null). ('a : value_or_null) Sexplib0.Sexp_grammar.t ->
('a : value_or_null) Base.global Sexplib0.Sexp_grammar.t @@ portableinclude sig ... end
val compare_portable :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> int) ->
('a : value_or_null) Base.portable ->
('a : value_or_null) Base.portable ->
intval compare_portable__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
int) ->
('a : value_or_null) Base.portable @ local ->
('a : value_or_null) Base.portable @ local ->
intval equal_portable :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> bool) ->
('a : value_or_null) Base.portable ->
('a : value_or_null) Base.portable ->
boolval equal_portable__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
bool) ->
('a : value_or_null) Base.portable @ local ->
('a : value_or_null) Base.portable @ local ->
boolval hash_fold_portable :
('a : value_or_null). (Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) ->
Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) Base.portable ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_portable :
('a : value_or_null). (('a : value_or_null) -> Sexplib0.Sexp.t) ->
('a : value_or_null) Base.portable ->
Sexplib0.Sexp.tval sexp_of_portable__stack :
('a : value_or_null). (('a : value_or_null) @ local ->
Sexplib0.Sexp.t @ local) ->
('a : value_or_null) Base.portable @ local ->
Sexplib0.Sexp.t @ localval portable_sexp_grammar :
('a : value_or_null). ('a : value_or_null) Sexplib0.Sexp_grammar.t ->
('a : value_or_null) Base.portable Sexplib0.Sexp_grammar.t @@ portableinclude sig ... end
val contended_of_sexp :
('a : value_or_null). (Sexplib0.Sexp.t -> ('a : value_or_null)) ->
Sexplib0.Sexp.t ->
('a : value_or_null) Base.contendedinclude sig ... end
include sig ... end
val hash_fold_many :
('a : value_or_null). (Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) ->
Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) Base.many ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_many :
('a : value_or_null). (('a : value_or_null) -> Sexplib0.Sexp.t) ->
('a : value_or_null) Base.many ->
Sexplib0.Sexp.tval sexp_of_many__stack :
('a : value_or_null). (('a : value_or_null) @ local ->
Sexplib0.Sexp.t @ local) ->
('a : value_or_null) Base.many @ local ->
Sexplib0.Sexp.t @ localval many_sexp_grammar :
('a : value_or_null). ('a : value_or_null) Sexplib0.Sexp_grammar.t ->
('a : value_or_null) Base.many Sexplib0.Sexp_grammar.t @@ portableinclude sig ... end
val compare_unyielding :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> int) ->
('a : value_or_null) Base.unyielding ->
('a : value_or_null) Base.unyielding ->
intval compare_unyielding__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
int) ->
('a : value_or_null) Base.unyielding @ local ->
('a : value_or_null) Base.unyielding @ local ->
intval equal_unyielding :
('a : value_or_null). (('a : value_or_null) -> ('a : value_or_null) -> bool) ->
('a : value_or_null) Base.unyielding ->
('a : value_or_null) Base.unyielding ->
boolval equal_unyielding__local :
('a : value_or_null). (('a : value_or_null) @ local ->
('a : value_or_null) @ local ->
bool) ->
('a : value_or_null) Base.unyielding @ local ->
('a : value_or_null) Base.unyielding @ local ->
boolval hash_fold_unyielding :
('a : value_or_null). (Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) ->
Ppx_hash_lib.Std.Hash.state) ->
Ppx_hash_lib.Std.Hash.state ->
('a : value_or_null) Base.unyielding ->
Ppx_hash_lib.Std.Hash.stateval sexp_of_unyielding :
('a : value_or_null). (('a : value_or_null) -> Sexplib0.Sexp.t) ->
('a : value_or_null) Base.unyielding ->
Sexplib0.Sexp.tval sexp_of_unyielding__stack :
('a : value_or_null). (('a : value_or_null) @ local ->
Sexplib0.Sexp.t @ local) ->
('a : value_or_null) Base.unyielding @ local ->
Sexplib0.Sexp.t @ localval unyielding_of_sexp :
('a : value_or_null). (Sexplib0.Sexp.t -> ('a : value_or_null)) ->
Sexplib0.Sexp.t ->
('a : value_or_null) Base.unyieldingval unyielding_sexp_grammar :
('a : value_or_null). ('a : value_or_null) Sexplib0.Sexp_grammar.t ->
('a : value_or_null) Base.unyielding Sexplib0.Sexp_grammar.t @@ portable