223 lines
10 KiB
Plaintext
223 lines
10 KiB
Plaintext
\chapter{The standard library} \label{c:stdlib}\cutname{stdlib.html}
|
|
|
|
This chapter describes the functions provided by the OCaml
|
|
standard library. The modules from the standard library are
|
|
automatically linked with the user's object code files by the "ocamlc"
|
|
command. Hence, these modules can be used in standalone programs without
|
|
having to add any ".cmo" file on the command line for the linking
|
|
phase. Similarly, in interactive use, these globals can be used in
|
|
toplevel phrases without having to load any ".cmo" file in memory.
|
|
|
|
Unlike the core "Stdlib" module, submodules are not automatically
|
|
``opened'' when compilation starts, or when the toplevel system is launched.
|
|
Hence it is necessary to use qualified identifiers to refer to the functions
|
|
provided by these modules, or to add "open" directives.
|
|
|
|
\label{stdlib:top}
|
|
|
|
\section*{s:stdlib-conv}{Conventions}
|
|
|
|
For easy reference, the modules are listed below in alphabetical order
|
|
of module names.
|
|
For each module, the declarations from its signature are printed
|
|
one by one in typewriter font, followed by a short comment.
|
|
All modules and the identifiers they export are indexed at the end of
|
|
this report.
|
|
|
|
\begin{latexonly}
|
|
\section*{s:stdlib-overview}{Overview}
|
|
|
|
Here is a short listing, by theme, of the standard library modules.
|
|
|
|
\subsubsection*{sss:stdlib-data-structures}{Data structures:}
|
|
\begin{tabular}{lll}
|
|
% Beware: these entries must be written in a very rigidly-defined
|
|
% format, or the check-stdlib-modules script will complain.
|
|
"String" & p.~\pageref{String} & string operations \\
|
|
"Bytes" & p.~\pageref{Bytes} & operations on byte sequences\\
|
|
"Array" & p.~\pageref{Array} & array operations \\
|
|
"List" & p.~\pageref{List} & list operations \\
|
|
"StdLabels" & p.~\pageref{StdLabels} & labelized versions of
|
|
the above 4 modules \\
|
|
"Unit" & p.~\pageref{Unit} & unit values \\
|
|
"Bool" & p.~\pageref{Bool} & boolean values \\
|
|
"Char" & p.~\pageref{Char} & character operations \\
|
|
"Uchar" & p.~\pageref{Uchar} & Unicode characters \\
|
|
"Int" & p.~\pageref{Int} & integer values \\
|
|
"Option" & p.~\pageref{Option} & option values \\
|
|
"Result" & p.~\pageref{Result} & result values \\
|
|
"Either" & p.~\pageref{Either} & either values \\
|
|
"Hashtbl" & p.~\pageref{Hashtbl} & hash tables and hash functions \\
|
|
"Random" & p.~\pageref{Random} & pseudo-random number generator \\
|
|
"Set" & p.~\pageref{Set} & sets over ordered types \\
|
|
"Map" & p.~\pageref{Map} & association tables over ordered types \\
|
|
"MoreLabels" & p.~\pageref{MoreLabels} & labelized versions of
|
|
"Hashtbl", "Set", and "Map" \\
|
|
"Oo" & p.~\pageref{Oo} & useful functions on objects \\
|
|
"Stack" & p.~\pageref{Stack} & last-in first-out stacks \\
|
|
"Queue" & p.~\pageref{Queue} & first-in first-out queues \\
|
|
"Buffer" & p.~\pageref{Buffer} & buffers that grow on demand \\
|
|
"Seq" & p.~\pageref{Seq} & functional iterators \\
|
|
"Lazy" & p.~\pageref{Lazy} & delayed evaluation \\
|
|
"Weak" & p.~\pageref{Weak} & references that don't prevent objects
|
|
from being garbage-collected \\
|
|
"Atomic" & p.~\pageref{Atomic} & atomic references (for compatibility with concurrent runtimes) \\
|
|
"Ephemeron" & p.~\pageref{Ephemeron} & ephemerons and weak hash tables \\
|
|
"Bigarray" & p.~\pageref{Bigarray} & large, multi-dimensional, numerical arrays
|
|
\end{tabular}
|
|
\subsubsection*{sss:stdlib-arith}{Arithmetic:}
|
|
\begin{tabular}{lll}
|
|
"Complex" & p.~\pageref{Complex} & Complex numbers \\
|
|
"Float" & p.~\pageref{Float} & Floating-point numbers \\
|
|
"Int32" & p.~\pageref{Int32} & operations on 32-bit integers \\
|
|
"Int64" & p.~\pageref{Int64} & operations on 64-bit integers \\
|
|
"Nativeint" & p.~\pageref{Nativeint} & operations on platform-native
|
|
integers
|
|
\end{tabular}
|
|
\subsubsection{sss:stdlib-io}{Input/output:}
|
|
\begin{tabular}{lll}
|
|
"Format" & p.~\pageref{Format} & pretty printing with automatic
|
|
indentation and line breaking \\
|
|
"Marshal" & p.~\pageref{Marshal} & marshaling of data structures \\
|
|
"Printf" & p.~\pageref{Printf} & formatting printing functions \\
|
|
"Scanf" & p.~\pageref{Scanf} & formatted input functions \\
|
|
"Digest" & p.~\pageref{Digest} & MD5 message digest \\
|
|
\end{tabular}
|
|
\subsubsection{sss:stdlib-parsing}{Parsing:}
|
|
\begin{tabular}{lll}
|
|
"Genlex" & p.~\pageref{Genlex} & a generic lexer over streams \\
|
|
"Lexing" & p.~\pageref{Lexing} & the run-time library for lexers generated by "ocamllex" \\
|
|
"Parsing" & p.~\pageref{Parsing} & the run-time library for parsers generated by "ocamlyacc" \\
|
|
"Stream" & p.~\pageref{Stream} & basic functions over streams \\
|
|
\end{tabular}
|
|
\subsubsection{sss:stdlib-system}{System interface:}
|
|
\begin{tabular}{lll}
|
|
"Arg" & p.~\pageref{Arg} & parsing of command line arguments \\
|
|
"Callback" & p.~\pageref{Callback} & registering OCaml functions to
|
|
be called from C \\
|
|
"Filename" & p.~\pageref{Filename} & operations on file names \\
|
|
"Gc" & p.~\pageref{Gc} & memory management control and statistics \\
|
|
"Printexc" & p.~\pageref{Printexc} & a catch-all exception handler \\
|
|
"Sys" & p.~\pageref{Sys} & system interface \\
|
|
\end{tabular}
|
|
\subsubsection{sss:stdlib-misc}{Misc:}
|
|
\begin{tabular}{lll}
|
|
"Fun" & p.~\pageref{Fun} & function values \\
|
|
\end{tabular}
|
|
\end{latexonly}
|
|
|
|
\ifouthtml
|
|
\begin{links}
|
|
\item \ahref{libref/Arg.html}{Module \texttt{Arg}: parsing of command line arguments}
|
|
\item \ahref{libref/Array.html}{Module \texttt{Array}: array operations}
|
|
\item \ahref{libref/ArrayLabels.html}{Module \texttt{ArrayLabels}: array operations (with labels)}
|
|
\item \ahref{libref/Atomic.html}{Module \texttt{Atomic}: atomic references}
|
|
\item \ahref{libref/Bigarray.html}{Module \texttt{Bigarray}: large, multi-dimensional, numerical arrays}
|
|
\item \ahref{libref/Bool.html}{Module \texttt{Bool}: boolean values}
|
|
\item \ahref{libref/Buffer.html}{Module \texttt{Buffer}: extensible buffers}
|
|
\item \ahref{libref/Bytes.html}{Module \texttt{Bytes}: byte sequences}
|
|
\item \ahref{libref/BytesLabels.html}{Module \texttt{BytesLabels}: byte sequences (with labels)}
|
|
\item \ahref{libref/Callback.html}{Module \texttt{Callback}: registering OCaml values with the C runtime}
|
|
\item \ahref{libref/Char.html}{Module \texttt{Char}: character operations}
|
|
\item \ahref{libref/Complex.html}{Module \texttt{Complex}: Complex numbers}
|
|
\item \ahref{libref/Digest.html}{Module \texttt{Digest}: MD5 message digest}
|
|
\item \ahref{libref/Either.html}{Module \texttt{Either}: either values}
|
|
\item \ahref{libref/Ephemeron.html}{Module \texttt{Ephemeron}: Ephemerons and weak hash table}
|
|
\item \ahref{libref/Filename.html}{Module \texttt{Filename}: operations on file names}
|
|
\item \ahref{libref/Float.html}{Module \texttt{Float}: Floating-point numbers}
|
|
\item \ahref{libref/Format.html}{Module \texttt{Format}: pretty printing}
|
|
\item \ahref{libref/Fun.html}{Module \texttt{Fun}: function values}
|
|
\item \ahref{libref/Gc.html}{Module \texttt{Gc}: memory management control and statistics; finalized values}
|
|
\item \ahref{libref/Genlex.html}{Module \texttt{Genlex}: a generic lexical analyzer}
|
|
\item \ahref{libref/Hashtbl.html}{Module \texttt{Hashtbl}: hash tables and hash functions}
|
|
\item \ahref{libref/Int.html}{Module \texttt{Int}: integers}
|
|
\item \ahref{libref/Int32.html}{Module \texttt{Int32}: 32-bit integers}
|
|
\item \ahref{libref/Int64.html}{Module \texttt{Int64}: 64-bit integers}
|
|
\item \ahref{libref/Lazy.html}{Module \texttt{Lazy}: deferred computations}
|
|
\item \ahref{libref/Lexing.html}{Module \texttt{Lexing}: the run-time library for lexers generated by \texttt{ocamllex}}
|
|
\item \ahref{libref/List.html}{Module \texttt{List}: list operations}
|
|
\item \ahref{libref/ListLabels.html}{Module \texttt{ListLabels}: list operations (with labels)}
|
|
\item \ahref{libref/Map.html}{Module \texttt{Map}: association tables over ordered types}
|
|
\item \ahref{libref/Marshal.html}{Module \texttt{Marshal}: marshaling of data structures}
|
|
\item \ahref{libref/MoreLabels.html}{Module \texttt{MoreLabels}: Include modules \texttt{Hashtbl}, \texttt{Map} and \texttt{Set} with labels}
|
|
\item \ahref{libref/Nativeint.html}{Module \texttt{Nativeint}: processor-native integers}
|
|
\item \ahref{libref/Oo.html}{Module \texttt{Oo}: object-oriented extension}
|
|
\item \ahref{libref/Option.html}{Module \texttt{Option}: option values}
|
|
\item \ahref{libref/Parsing.html}{Module \texttt{Parsing}: the run-time library for parsers generated by \texttt{ocamlyacc}}
|
|
\item \ahref{libref/Printexc.html}{Module \texttt{Printexc}: facilities for printing exceptions}
|
|
\item \ahref{libref/Printf.html}{Module \texttt{Printf}: formatting printing functions}
|
|
\item \ahref{libref/Queue.html}{Module \texttt{Queue}: first-in first-out queues}
|
|
\item \ahref{libref/Random.html}{Module \texttt{Random}: pseudo-random number generator (PRNG)}
|
|
\item \ahref{libref/Result.html}{Module \texttt{Result}: result values}
|
|
\item \ahref{libref/Scanf.html}{Module \texttt{Scanf}: formatted input functions}
|
|
\item \ahref{libref/Seq.html}{Module \texttt{Seq}: functional iterators}
|
|
\item \ahref{libref/Set.html}{Module \texttt{Set}: sets over ordered types}
|
|
\item \ahref{libref/Stack.html}{Module \texttt{Stack}: last-in first-out stacks}
|
|
\item \ahref{libref/StdLabels.html}{Module \texttt{StdLabels}: Include modules \texttt{Array}, \texttt{List} and \texttt{String} with labels}
|
|
\item \ahref{libref/Stream.html}{Module \texttt{Stream}: streams and parsers}
|
|
\item \ahref{libref/String.html}{Module \texttt{String}: string operations}
|
|
\item \ahref{libref/StringLabels.html}{Module \texttt{StringLabels}: string operations (with labels)}
|
|
\item \ahref{libref/Sys.html}{Module \texttt{Sys}: system interface}
|
|
\item \ahref{libref/Uchar.html}{Module \texttt{Uchar}: Unicode characters}
|
|
\item \ahref{libref/Unit.html}{Module \texttt{Unit}: unit values}
|
|
\item \ahref{libref/Weak.html}{Module \texttt{Weak}: arrays of weak pointers}
|
|
\end{links}
|
|
\else
|
|
{\ocamldocinputstart
|
|
\input{Arg.tex}
|
|
\input{Array.tex}
|
|
\input{ArrayLabels.tex}
|
|
\input{Atomic.tex}
|
|
\input{Bigarray.tex}
|
|
\input{Bool.tex}
|
|
\input{Buffer.tex}
|
|
\input{Bytes.tex}
|
|
\input{BytesLabels.tex}
|
|
\input{Callback.tex}
|
|
\input{Char.tex}
|
|
\input{Complex.tex}
|
|
\input{Digest.tex}
|
|
\input{Either.tex}
|
|
\input{Ephemeron.tex}
|
|
\input{Filename.tex}
|
|
\input{Float.tex}
|
|
\input{Format.tex}
|
|
\input{Fun.tex}
|
|
\input{Gc.tex}
|
|
\input{Genlex.tex}
|
|
\input{Hashtbl.tex}
|
|
\input{Int.tex}
|
|
\input{Int32.tex}
|
|
\input{Int64.tex}
|
|
\input{Lazy.tex}
|
|
\input{Lexing.tex}
|
|
\input{List.tex}
|
|
\input{ListLabels.tex}
|
|
\input{Map.tex}
|
|
\input{Marshal.tex}
|
|
\input{MoreLabels.tex}
|
|
\input{Nativeint.tex}
|
|
\input{Oo.tex}
|
|
\input{Option.tex}
|
|
\input{Parsing.tex}
|
|
\input{Printexc.tex}
|
|
\input{Printf.tex}
|
|
\input{Queue.tex}
|
|
\input{Random.tex}
|
|
\input{Result.tex}
|
|
\input{Scanf.tex}
|
|
\input{Seq.tex}
|
|
\input{Set.tex}
|
|
\input{Stack.tex}
|
|
\input{StdLabels.tex}
|
|
\input{Stream.tex}
|
|
\input{String.tex}
|
|
\input{StringLabels.tex}
|
|
\input{Sys.tex}
|
|
\input{Uchar.tex}
|
|
\input{Unit.tex}
|
|
\input{Weak.tex}
|
|
\input{Ocamloperators.tex}
|
|
}
|
|
\fi
|