include Base
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 'b
Base 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 = Base.Applicative
module Array = Base.Array
module Avltree = Base.Avltree
module Backtrace = Base.Backtrace
module Binary_search = Base.Binary_search
module Binary_searchable = Base.Binary_searchable
module Blit = Base.Blit
module Bool = Base.Bool
module Buffer = Base.Buffer
module Bytes = Base.Bytes
module Char = Base.Char
module Commutative_group = Base.Commutative_group
module Comparable = Base.Comparable
module Comparator = Base.Comparator
module Comparisons = Base.Comparisons
module Container = Base.Container
module Either = Base.Either
module Equal = Base.Equal
module Error = Base.Error
module Exn = Base.Exn
module Field = Base.Field
module Float = Base.Float
module Floatable = Base.Floatable
module Fn = Base.Fn
module Formatter = Base.Formatter
module Hash = Base.Hash
module Hash_set = Base.Hash_set
module Hashable = Base.Hashable
module Hasher = Base.Hasher
module Hashtbl = Base.Hashtbl
module Heap_block = Base.Heap_block
module Identifiable = Base.Identifiable
module Indexed_container = Base.Indexed_container
module Info = Base.Info
module Int = Base.Int
module Int32 = Base.Int32
module Int63 = Base.Int63
module Int64 = Base.Int64
module Intable = Base.Intable
module Invariant = Base.Invariant
module Lazy = Base.Lazy
module List = Base.List
module Map = Base.Map
module Maybe_bound = Base.Maybe_bound
module Monad = Base.Monad
module Nativeint = Base.Nativeint
module Option = Base.Option
module Option_array = Base.Option_array
module Or_error = Base.Or_error
module Ordered_collection_common = Base.Ordered_collection_common
module Ordering = Base.Ordering
module Poly = Base.Poly
Poly
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 = Base.Polymorphic_compare
module Popcount = Base.Popcount
module Pretty_printer = Base.Pretty_printer
module Printf = Base.Printf
module Linked_queue = Base.Linked_queue
module Queue = Base.Queue
module Random = Base.Random
module Ref = Base.Ref
module Result = Base.Result
module Sequence = Base.Sequence
module Set = Base.Set
module Sexpable = Base.Sexpable
module Sign = Base.Sign
module Source_code_position = Base.Source_code_position
module Staged = Base.Staged
module String = Base.String
module Stringable = Base.Stringable
module Sys = Base.Sys
module T = Base.T
module Type_equal = Base.Type_equal
module Uniform_array = Base.Uniform_array
module Unit = Base.Unit
module Uchar = Base.Uchar
module Validate = Base.Validate
module Variant = Base.Variant
module With_return = Base.With_return
module Word_size = Base.Word_size
include T
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.
module type T : sig ... end
module type T1 : sig ... end
module type T2 : sig ... end
module type T3 : sig ... end
module Sexp = Base.Sexp
module Export = Base.Export
include Export
val hash_fold_bool : Hash.state ‑> bool ‑> Hash.state
val hash_bool : bool ‑> Hash.hash_value
val hash_fold_char : Hash.state ‑> char ‑> Hash.state
val hash_char : char ‑> Hash.hash_value
val hash_fold_float : Hash.state ‑> float ‑> Hash.state
val hash_float : float ‑> Hash.hash_value
val hash_fold_int : Hash.state ‑> int ‑> Hash.state
val hash_int : int ‑> Hash.hash_value
val hash_fold_int32 : Hash.state ‑> int32 ‑> Hash.state
val hash_int32 : int32 ‑> Hash.hash_value
val hash_fold_int64 : Hash.state ‑> int64 ‑> Hash.state
val hash_int64 : int64 ‑> Hash.hash_value
val hash_fold_list : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a list ‑> Hash.state
val hash_fold_nativeint : Hash.state ‑> nativeint ‑> Hash.state
val hash_nativeint : nativeint ‑> Hash.hash_value
val hash_fold_option : a. (Hash.state ‑> 'a ‑> Hash.state) ‑> Hash.state ‑> 'a option ‑> Hash.state
val hash_fold_string : Hash.state ‑> string ‑> Hash.state
val hash_string : string ‑> Hash.hash_value
val hash_fold_unit : Hash.state ‑> unit ‑> Hash.state
val hash_unit : unit ‑> Hash.hash_value
Format 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 None
sexp_opaque
causes the conversion to sexp to produce the atom <opaque>
.
For more documentation, see sexplib/README.md.
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.
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 (+.) : Base.Float.t ‑> Base.Float.t ‑> Base.Float.t
val (-.) : Base.Float.t ‑> Base.Float.t ‑> Base.Float.t
val (*.) : Base.Float.t ‑> Base.Float.t ‑> Base.Float.t
val (/.) : Base.Float.t ‑> Base.Float.t ‑> Base.Float.t
val (**.) : Base.Float.t ‑> Base.Float.t ‑> Base.Float.t
val (~-.) : Base.Float.t ‑> Base.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))
.
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 ‑> 'a
Misc
external force : 'a Lazy.t ‑> 'a = "%lazy_force"
module Continue_or_stop = Base__.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.
exception
Not_found_s of Sexplib0.Sexp.t
module Not_exposed_properly = Base.Not_exposed_properly