This module is the toplevel of the Base library; it's what you get when you write
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 their initial environment.
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, and Comparisons in lieu of polymorphic compare.Container, which provides a consistent interface across container-like data
structures (arrays, lists, strings).Result, Error, and Or_error, supporting the or-error pattern.Broadly 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.
module Applicative : sig ... endmodule Binary_search : sig ... endGeneral functions for performing binary searches over ordered sequences given
length and get functions.
module Binary_searchable : sig ... endmodule Blit : sig ... endmodule Bool : sig ... endBoolean type extended to be enumerable, hashable, sexpable, comparable, and stringable.
module Bytes : sig ... endOCaml's byte sequence type, semantically similar to a char array, but
taking less space in memory.
module Commutative_group : sig ... endA signature for a commutative group (in the group-theory sense).
module Comparable : sig ... endmodule Comparator : sig ... endA type-indexed value that allows one to compare (and for generating error messages, serialize) values of the type in question.
module Container : sig ... endmodule Either : sig ... endmodule Equal : sig ... endThis 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 ... endA lazy string, implemented with Info, but intended specifically for error
messages.
module Formatter : sig ... endThe Format.formatter type from OCaml's standard library, exported here
for convenience and compatibility with other libraries.
module Hash : sig ... endmodule Hash_set : sig ... endmodule Hashable : sig ... endmodule Hasher : sig ... endSignatures required of types which can be used in [@@deriving_inline hash][@@@end].
module Hashtbl : sig ... endHash tables, mutable lookup-tables supporting constant-time lookup and in-place modification.
module Heap_block : sig ... endA 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.
module Identifiable : sig ... endA signature combining functionality that is commonly used for types that are intended to act as names or identifiers.
module Indexed_container : sig ... endmodule Info : sig ... endmodule Int : sig ... endmodule Invariant : sig ... endmodule Lazy : sig ... endA value of type 'a Lazy.t is a deferred computation, called a suspension, that has a
result of type 'a.
module List : sig ... endImmutable, 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.
module Map : sig ... endmodule Maybe_bound : sig ... endUsed for specifying a bound (either upper or lower) as inclusive, exclusive, or unbounded.
module Monad : sig ... endmodule Option_array : sig ... end'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.
module Or_error : sig ... endType for tracking errors in an Error.t. This is a specialization of the Result
type, where the Error constructor carries an Error.t.
module Ordering : sig ... endOrdering is intended to make code that matches on the result of a comparison
more concise and easier to read.
module Poly : sig ... endPoly is a convenient shorthand for Polymorphic_compare in the common case that one
wants to use a polymorphic comparator directly in an expression, e.g., Poly.equal a
b.
module Polymorphic_compare : sig ... endmodule Popcount : sig ... endThis module exposes popcount functions (which count the number of ones in a bitstring) for the various integer types.
module Pretty_printer : sig ... endA list of pretty printers for various types, for use in toplevels.
module Linked_queue : sig ... endThis module is a Base-style wrapper around OCaml's standard Queue module.
module Queue : sig ... endmodule Ref : sig ... endModule for the type ref, mutable indirection cells r containing a value of type
'a, accessed with !r and set by r := a.
module Sequence : sig ... endA sequence of elements that can be produced one at a time, on demand, normally with no sharing.
module Set : sig ... endmodule Sexpable : sig ... endProvides functors for making modules sexpable. New code should use the [@@deriving
sexp] syntax directly. These module types (S, S1, S2, and S3) are exported
for backwards compatibility only.
module Source_code_position : sig ... endOne typically obtains a Source_code_position.t using a [%here] expression, which
is implemented by the ppx_here preprocessor.
module String : sig ... endAn extension of the standard StringLabels. If you open Base, you'll get these
extensions in the String module.
module T : sig ... endThis 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.
module Type_equal : sig ... endThe purpose of Type_equal is to represent type equalities that the type checker
otherwise would not know, perhaps because the type equality depends on dynamic data,
or perhaps because the type system isn't powerful enough.
module Uniform_array : sig ... endSame 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.
module Variant : sig ... endFirst-class representative of an individual variant in a variant type, used in
[@@deriving_inline variants][@@@end].
module With_return : sig ... endwith_return f allows for something like the return statement in C within f.
include TThis 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.
module type T : sig ... endmodule type T1 : sig ... endmodule type T2 : sig ... endmodule type T3 : sig ... endmodule Sexp : sig ... endmodule Export : sig ... endinclude Exportval hash_fold_bool : Hash.state ‑> bool ‑> Hash.stateval hash_bool : bool ‑> Hash.hash_valueval hash_fold_char : Hash.state ‑> char ‑> Hash.stateval hash_char : char ‑> Hash.hash_valueval hash_fold_float : Hash.state ‑> float ‑> Hash.stateval hash_float : float ‑> Hash.hash_valueval hash_fold_int : Hash.state ‑> int ‑> Hash.stateval hash_int : int ‑> Hash.hash_valueval hash_fold_int32 : Hash.state ‑> int32 ‑> Hash.stateval hash_int32 : int32 ‑> Hash.hash_valueval hash_fold_int64 : Hash.state ‑> int64 ‑> Hash.stateval hash_int64 : int64 ‑> Hash.hash_valueval hash_fold_list : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a list ‑> Hash.stateval hash_fold_nativeint : Hash.state ‑> nativeint ‑> Hash.stateval hash_nativeint : nativeint ‑> Hash.hash_valueval hash_fold_option : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a option ‑> Hash.stateval hash_fold_string : Hash.state ‑> string ‑> Hash.stateval hash_string : string ‑> Hash.hash_valueval hash_fold_unit : Hash.state ‑> unit ‑> Hash.stateval hash_unit : unit ‑> Hash.hash_valueFormat stuff
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 Nonesexp_opaque causes the conversion to sexp to produce the atom <opaque>.
For more documentation, see sexplib/README.md.
List operators
include List.Infixval (@) : 'a Base__List.t ‑> 'a Base__List.t ‑> 'a Base__List.tInt operators and comparisons
include Int.OA sub-module designed to be opened to make working with ints more convenient.
Float operators
include Float.O_dotSimilar 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.
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)).
Boolean operations
external ignore : _ ‑> unit = "%ignore" Reference operations
external (!) : 'a ref ‑> 'a = "%field0" external ref : 'a ‑> 'a ref = "%makemutable" Pair operations
Exceptions stuff
val raise_s : Sexp.t ‑> 'aMisc
external force : 'a Lazy.t ‑> 'a = "%lazy_force" module Continue_or_stop = Base__.Container_intf.Export.Continue_or_stopContinue_or_stop.t is used by the f argument to fold_until in order to
indicate whether folding should continue, or stop early.
exception Not_found_s of Sexplib0.Sexp.tmodule Not_exposed_properly : sig ... end