<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> <meta name="generator" content="hevea 2.00"> <link rel="stylesheet" type="text/css" href="manual.css"> <title>The core library</title> </head> <body> <a href="intfc.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="index.html"><img src="contents_motif.gif" alt="Up"></a> <a href="stdlib.html"><img src="next_motif.gif" alt="Next"></a> <hr> <h1 class="chapter" id="sec462">Chapter 20  The core library</h1> <ul> <li><a href="core.html#sec463">Conventions</a> </li><li><a href="core.html#sec464">Built-in types and predefined exceptions</a> </li><li><a href="core.html#sec467">Module <span class="c007">Pervasives</span>: the initially opened module</a> </li></ul> <p> <a id="c:corelib"></a></p><p>This chapter describes the OCaml core library, which is composed of declarations for built-in types and exceptions, plus the module <span class="c007">Pervasives</span> that provides basic operations on these built-in types. The <span class="c007">Pervasives</span> module is special in two ways: </p><ul class="itemize"><li class="li-itemize"> It is automatically linked with the user’s object code files by the <span class="c007">ocamlc</span> command (chapter <a href="comp.html#c%3Acamlc">8</a>).</li><li class="li-itemize">It is automatically “opened” when a compilation starts, or when the toplevel system is launched. Hence, it is possible to use unqualified identifiers to refer to the functions provided by the <span class="c007">Pervasives</span> module, without adding a <span class="c007">open Pervasives</span> directive. </li></ul><h2 class="section" id="sec463">Conventions</h2> <p>The declarations of the built-in types and the components of module <span class="c007">Pervasives</span> are printed one by one in typewriter font, followed by a short comment. All library modules and the components they provide are indexed at the end of this report.</p> <h2 class="section" id="sec464">20.1  Built-in types and predefined exceptions</h2> <p>The following built-in types and predefined exceptions are always defined in the compilation environment, but are not part of any module. As a consequence, they can only be referred by their short names.</p><h3 class="subsection" id="sec465">Built-in types</h3> <pre> type int </pre><p><a id="hevea_manual9"></a> </p><blockquote class="quote"> The type of integer numbers. </blockquote><pre> type char </pre><p><a id="hevea_manual10"></a> </p><blockquote class="quote"> The type of characters. </blockquote><pre> type string </pre><p><a id="hevea_manual11"></a> </p><blockquote class="quote"> The type of character strings. </blockquote><pre> type float </pre><p><a id="hevea_manual12"></a> </p><blockquote class="quote"> The type of floating-point numbers. </blockquote><pre> type bool = false | true </pre><p><a id="hevea_manual13"></a> </p><blockquote class="quote"> The type of booleans (truth values). </blockquote><pre> type unit = () </pre><p><a id="hevea_manual14"></a> </p><blockquote class="quote"> The type of the unit value. </blockquote><pre> type exn </pre><p><a id="hevea_manual15"></a> </p><blockquote class="quote"> The type of exception values. </blockquote><pre> type 'a array </pre><p><a id="hevea_manual16"></a> </p><blockquote class="quote"> The type of arrays whose elements have type <span class="c007">'a</span>. </blockquote><pre> type 'a list = [] | :: of 'a * 'a list </pre><p><a id="hevea_manual17"></a> </p><blockquote class="quote"> The type of lists whose elements have type <span class="c007">'a</span>. </blockquote><pre>type 'a option = None | Some of 'a </pre><p><a id="hevea_manual18"></a> </p><blockquote class="quote"> The type of optional values of type <span class="c007">'a</span>. </blockquote><pre>type int32 </pre><p><a id="hevea_manual19"></a> </p><blockquote class="quote"> The type of signed 32-bit integers. See the <span class="c007">Int32</span>[<a href="libref/Int32.html"><span class="c007">Int32</span></a>] module. </blockquote><pre>type int64 </pre><p><a id="hevea_manual20"></a> </p><blockquote class="quote"> The type of signed 64-bit integers. See the <span class="c007">Int64</span>[<a href="libref/Int64.html"><span class="c007">Int64</span></a>] module. </blockquote><pre>type nativeint </pre><p><a id="hevea_manual21"></a> </p><blockquote class="quote"> The type of signed, platform-native integers (32 bits on 32-bit processors, 64 bits on 64-bit processors). See the <span class="c007">Nativeint</span>[<a href="libref/Nativeint.html"><span class="c007">Nativeint</span></a>] module. </blockquote><pre>type ('a, 'b, 'c, 'd, 'e, 'f) format6 </pre><p><a id="hevea_manual22"></a> </p><blockquote class="quote"> The type of format strings. <span class="c007">'a</span> is the type of the parameters of the format, <span class="c007">'f</span> is the result type for the <span class="c007">printf</span>-style functions, <span class="c007">'b</span> is the type of the first argument given to <span class="c007">%a</span> and <span class="c007">%t</span> printing functions (see module <span class="c007">Printf</span>[<a href="libref/Printf.html"><span class="c007">Printf</span></a>]), <span class="c007">'c</span> is the result type of these functions, and also the type of the argument transmitted to the first argument of <span class="c007">kprintf</span>-style functions, <span class="c007">'d</span> is the result type for the <span class="c007">scanf</span>-style functions (see module <span class="c007">Scanf</span>[<a href="libref/Scanf.html"><span class="c007">Scanf</span></a>]), and <span class="c007">'e</span> is the type of the receiver function for the <span class="c007">scanf</span>-style functions. </blockquote><pre>type 'a lazy_t </pre><p><a id="hevea_manual23"></a> </p><blockquote class="quote"> This type is used to implement the <span class="c007">Lazy</span>[<a href="libref/Lazy.html"><span class="c007">Lazy</span></a>] module. It should not be used directly. </blockquote><h3 class="subsection" id="sec466">Predefined exceptions</h3> <pre>exception Match_failure of (string * int * int) </pre><p><a id="hevea_manual24"></a> </p><blockquote class="quote"> Exception raised when none of the cases of a pattern-matching apply. The arguments are the location of the <span class="c007">match</span> keyword in the source code (file name, line number, column number). </blockquote><pre>exception Assert_failure of (string * int * int) </pre><p><a id="hevea_manual25"></a> </p><blockquote class="quote"> Exception raised when an assertion fails. The arguments are the location of the <span class="c007">assert</span> keyword in the source code (file name, line number, column number). </blockquote><pre>exception Invalid_argument of string </pre><p><a id="hevea_manual26"></a> </p><blockquote class="quote"> Exception raised by library functions to signal that the given arguments do not make sense. </blockquote><pre>exception Failure of string </pre><p><a id="hevea_manual27"></a> </p><blockquote class="quote"> Exception raised by library functions to signal that they are undefined on the given arguments. </blockquote><pre>exception Not_found </pre><p><a id="hevea_manual28"></a> </p><blockquote class="quote"> Exception raised by search functions when the desired object could not be found. </blockquote><pre>exception Out_of_memory </pre><p><a id="hevea_manual29"></a> </p><blockquote class="quote"> Exception raised by the garbage collector when there is insufficient memory to complete the computation. </blockquote><pre>exception Stack_overflow </pre><p><a id="hevea_manual30"></a> </p><blockquote class="quote"> Exception raised by the bytecode interpreter when the evaluation stack reaches its maximal size. This often indicates infinite or excessively deep recursion in the user’s program. (Not fully implemented by the native-code compiler; see section <a href="native.html#s%3Acompat-native-bytecode">11.5</a>.) </blockquote><pre>exception Sys_error of string </pre><p><a id="hevea_manual31"></a> </p><blockquote class="quote"> Exception raised by the input/output functions to report an operating system error. </blockquote><pre>exception End_of_file </pre><p><a id="hevea_manual32"></a> </p><blockquote class="quote"> Exception raised by input functions to signal that the end of file has been reached. </blockquote><pre>exception Division_by_zero </pre><p><a id="hevea_manual33"></a> </p><blockquote class="quote"> Exception raised by integer division and remainder operations when their second argument is zero. </blockquote><pre>exception Sys_blocked_io </pre><p><a id="hevea_manual34"></a> </p><blockquote class="quote"> A special case of <span class="c007">Sys_error</span> raised when no I/O is possible on a non-blocking I/O channel. </blockquote><pre>exception Undefined_recursive_module of (string * int * int) </pre><p><a id="hevea_manual35"></a> </p><blockquote class="quote"> Exception raised when an ill-founded recursive module definition is evaluated. (See section <a href="extn.html#s-recursive-modules">7.8</a>.) The arguments are the location of the definition in the source code (file name, line number, column number). </blockquote> <h2 class="section" id="sec467">20.2  Module <span class="c007">Pervasives</span>: the initially opened module</h2> <ul class="ftoc2"><li class="li-links"> <a href="libref/Pervasives.html">Module <span class="c007">Pervasives</span>: the initially opened module</a> </li></ul> <hr> <a href="intfc.html"><img src="previous_motif.gif" alt="Previous"></a> <a href="index.html"><img src="contents_motif.gif" alt="Up"></a> <a href="stdlib.html"><img src="next_motif.gif" alt="Next"></a> </body> </html>