Module Caml
include Stdlib
Exceptions
exceptionExitThe
Exitexception is not raised by any library function. It is provided for use in your programs.
exceptionMatch_failure of string * int * intException raised when none of the cases of a pattern-matching apply. The arguments are the location of the match keyword in the source code (file name, line number, column number).
exceptionAssert_failure of string * int * intException raised when an assertion fails. The arguments are the location of the assert keyword in the source code (file name, line number, column number).
exceptionInvalid_argument of stringException raised by library functions to signal that the given arguments do not make sense. The string gives some information to the programmer. As a general rule, this exception should not be caught, it denotes a programming error and the code should be modified not to trigger it.
exceptionFailure of stringException raised by library functions to signal that they are undefined on the given arguments. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Failure _ instead).
exceptionOut_of_memoryException raised by the garbage collector when there is insufficient memory to complete the computation.
exceptionStack_overflowException 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.)
exceptionSys_error of stringException raised by the input/output functions to report an operating system error. The string is meant to give some information to the programmer; you must not pattern match on the string literal because it may change in future versions (use Sys_error _ instead).
exceptionEnd_of_fileException raised by input functions to signal that the end of file has been reached.
exceptionDivision_by_zeroException raised by integer division and remainder operations when their second argument is zero.
Comparisons
val (=) : 'a -> 'a -> boole1 = e2tests for structural equality ofe1ande2. Mutable structures (e.g. references and arrays) are equal if and only if their current contents are structurally equal, even if the two mutable objects are not the same physical object. Equality between functional values raisesInvalid_argument. Equality between cyclic data structures may not terminate. Left-associative operator, seeOcaml_operatorsfor more information.
val (<>) : 'a -> 'a -> boolNegation of
Stdlib.( = ). Left-associative operator, seeOcaml_operatorsfor more information.
val (<) : 'a -> 'a -> boolSee
Stdlib.( >= ). Left-associative operator, seeOcaml_operatorsfor more information.
val (>) : 'a -> 'a -> boolSee
Stdlib.( >= ). Left-associative operator, seeOcaml_operatorsfor more information.
val (<=) : 'a -> 'a -> boolSee
Stdlib.( >= ). Left-associative operator, seeOcaml_operatorsfor more information.
val (>=) : 'a -> 'a -> boolStructural ordering functions. These functions coincide with the usual orderings over integers, characters, strings, byte sequences and floating-point numbers, and extend them to a total ordering over all types. The ordering is compatible with
( = ). As in the case of( = ), mutable structures are compared by contents. Comparison between functional values raisesInvalid_argument. Comparison between cyclic structures may not terminate. Left-associative operator, seeOcaml_operatorsfor more information.
val compare : 'a -> 'a -> intcompare x yreturns0ifxis equal toy, a negative integer ifxis less thany, and a positive integer ifxis greater thany. The ordering implemented bycompareis compatible with the comparison predicates=,<and>defined above, with one difference on the treatment of the float valueStdlib.nan. Namely, the comparison predicates treatnanas different from any other float value, including itself; whilecomparetreatsnanas equal to itself and less than any other float value. This treatment ofnanensures thatcomparedefines a total ordering relation.compareapplied to functional values may raiseInvalid_argument.compareapplied to cyclic structures may not terminate.The
comparefunction can be used as the comparison function required by theSet.MakeandMap.Makefunctors, as well as theList.sortandArray.sortfunctions.
val min : 'a -> 'a -> 'aReturn the smaller of the two arguments. The result is unspecified if one of the arguments contains the float value
nan.
val max : 'a -> 'a -> 'aReturn the greater of the two arguments. The result is unspecified if one of the arguments contains the float value
nan.
val (==) : 'a -> 'a -> boole1 == e2tests for physical equality ofe1ande2. On mutable types such as references, arrays, byte sequences, records with mutable fields and objects with mutable instance variables,e1 == e2is true if and only if physical modification ofe1also affectse2. On non-mutable types, the behavior of( == )is implementation-dependent; however, it is guaranteed thate1 == e2impliescompare e1 e2 = 0. Left-associative operator, seeOcaml_operatorsfor more information.
Boolean operations
val (&&) : bool -> bool -> boolThe boolean 'and'. Evaluation is sequential, left-to-right: in
e1 && e2,e1is evaluated first, and if it returnsfalse,e2is not evaluated at all. Right-associative operator, seeOcaml_operatorsfor more information.
val (&) : bool -> bool -> bool- deprecated
Stdlib.( && ) should be used instead. Right-associative operator, seeOcaml_operatorsfor more information.
Debugging
val __LOC__ : string__LOC__returns the location at which this expression appears in the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".- since
- 4.02.0
val __FILE__ : string__FILE__returns the name of the file currently being parsed by the compiler.- since
- 4.02.0
val __LINE__ : int__LINE__returns the line number at which this expression appears in the file currently being parsed by the compiler.- since
- 4.02.0
val __MODULE__ : string__MODULE__returns the module name of the file being parsed by the compiler.- since
- 4.02.0
val __POS__ : string * int * int * int__POS__returns a tuple(file,lnum,cnum,enum), corresponding to the location at which this expression appears in the file currently being parsed by the compiler.fileis the current filename,lnumthe line number,cnumthe character position in the line andenumthe last character position in the line.- since
- 4.02.0
val __LOC_OF__ : 'a -> string * 'a__LOC_OF__ exprreturns a pair(loc, expr)wherelocis the location ofexprin the file currently being parsed by the compiler, with the standard error format of OCaml: "File %S, line %d, characters %d-%d".- since
- 4.02.0
val __LINE_OF__ : 'a -> int * 'a__LINE_OF__ exprreturns a pair(line, expr), wherelineis the line number at which the expressionexprappears in the file currently being parsed by the compiler.- since
- 4.02.0
val __POS_OF__ : 'a -> (string * int * int * int) * 'a__POS_OF__ exprreturns a pair(loc,expr), wherelocis a tuple(file,lnum,cnum,enum)corresponding to the location at which the expressionexprappears in the file currently being parsed by the compiler.fileis the current filename,lnumthe line number,cnumthe character position in the line andenumthe last character position in the line.- since
- 4.02.0
Composition operators
Integer arithmetic
val (~-) : int -> intUnary negation. You can also write
- einstead of~- e. Unary operator, seeOcaml_operatorsfor more information.
val (~+) : int -> intUnary addition. You can also write
+ einstead of~+ e. Unary operator, seeOcaml_operatorsfor more information.- since
- 3.12.0
val (+) : int -> int -> intInteger addition. Left-associative operator, see
Ocaml_operatorsfor more information.
val (-) : int -> int -> intInteger subtraction. Left-associative operator, , see
Ocaml_operatorsfor more information.
val (*) : int -> int -> intInteger multiplication. Left-associative operator, see
Ocaml_operatorsfor more information.
val (/) : int -> int -> intInteger division. Raise
Division_by_zeroif the second argument is 0. Integer division rounds the real quotient of its arguments towards zero. More precisely, ifx >= 0andy > 0,x / yis the greatest integer less than or equal to the real quotient ofxbyy. Moreover,(- x) / y = x / (- y) = - (x / y). Left-associative operator, seeOcaml_operatorsfor more information.
val (mod) : int -> int -> intInteger remainder. If
yis not zero, the result ofx mod ysatisfies the following properties:x = (x / y) * y + x mod yandabs(x mod y) <= abs(y) - 1. Ify = 0,x mod yraisesDivision_by_zero. Note thatx mod yis negative only ifx < 0. RaiseDivision_by_zeroifyis zero. Left-associative operator, seeOcaml_operatorsfor more information.
val abs : int -> intReturn the absolute value of the argument. Note that this may be negative if the argument is
min_int.
Bitwise operations
val (land) : int -> int -> intBitwise logical and. Left-associative operator, see
Ocaml_operatorsfor more information.
val (lor) : int -> int -> intBitwise logical or. Left-associative operator, see
Ocaml_operatorsfor more information.
val (lxor) : int -> int -> intBitwise logical exclusive or. Left-associative operator, see
Ocaml_operatorsfor more information.
val (lsl) : int -> int -> intn lsl mshiftsnto the left bymbits. The result is unspecified ifm < 0orm > Sys.int_size. Right-associative operator, seeOcaml_operatorsfor more information.
Floating-point arithmetic
OCaml's floating-point numbers follow the IEEE 754 standard, using double precision (64 bits) numbers. Floating-point operations never raise an exception on overflow, underflow, division by zero, etc. Instead, special IEEE numbers are returned as appropriate, such as infinity for 1.0 /. 0.0, neg_infinity for -1.0 /. 0.0, and nan ('not a number') for 0.0 /. 0.0. These special numbers then propagate through floating-point computations as expected: for instance, 1.0 /. infinity is 0.0, and any arithmetic operation with nan as argument returns nan as result.
val (~-.) : float -> floatUnary negation. You can also write
-. einstead of~-. e. Unary operator, seeOcaml_operatorsfor more information.
val (~+.) : float -> floatUnary addition. You can also write
+. einstead of~+. e. Unary operator, seeOcaml_operatorsfor more information.- since
- 3.12.0
val (+.) : float -> float -> floatFloating-point addition. Left-associative operator, see
Ocaml_operatorsfor more information.
val (-.) : float -> float -> floatFloating-point subtraction. Left-associative operator, see
Ocaml_operatorsfor more information.
val (*.) : float -> float -> floatFloating-point multiplication. Left-associative operator, see
Ocaml_operatorsfor more information.
val (/.) : float -> float -> floatFloating-point division. Left-associative operator, see
Ocaml_operatorsfor more information.
val (**) : float -> float -> floatExponentiation. Right-associative operator, see
Ocaml_operatorsfor more information.
val expm1 : float -> floatexpm1 xcomputesexp x -. 1.0, giving numerically-accurate results even ifxis close to0.0.- since
- 3.12.0
val log1p : float -> floatlog1p xcomputeslog(1.0 +. x)(natural logarithm), giving numerically-accurate results even ifxis close to0.0.- since
- 3.12.0
val acos : float -> floatArc cosine. The argument must fall within the range
[-1.0, 1.0]. Result is in radians and is between0.0andpi.
val asin : float -> floatArc sine. The argument must fall within the range
[-1.0, 1.0]. Result is in radians and is between-pi/2andpi/2.
val atan2 : float -> float -> floatatan2 y xreturns the arc tangent ofy /. x. The signs ofxandyare used to determine the quadrant of the result. Result is in radians and is between-piandpi.
val hypot : float -> float -> floathypot x yreturnssqrt(x *. x + y *. y), that is, the length of the hypotenuse of a right-angled triangle with sides of lengthxandy, or, equivalently, the distance of the point(x,y)to origin. If one ofxoryis infinite, returnsinfinityeven if the other isnan.- since
- 4.00.0
val ceil : float -> floatRound above to an integer value.
ceil freturns the least integer value greater than or equal tof. The result is returned as a float.
val floor : float -> floatRound below to an integer value.
floor freturns the greatest integer value less than or equal tof. The result is returned as a float.
val copysign : float -> float -> floatcopysign x yreturns a float whose absolute value is that ofxand whose sign is that ofy. Ifxisnan, returnsnan. Ifyisnan, returns eitherxor-. x, but it is not specified which.- since
- 4.00.0
val mod_float : float -> float -> floatmod_float a breturns the remainder ofawith respect tob. The returned value isa -. n *. b, wherenis the quotienta /. brounded towards zero to an integer.
val frexp : float -> float * intfrexp freturns the pair of the significant and the exponent off. Whenfis zero, the significantxand the exponentnoffare equal to zero. Whenfis non-zero, they are defined byf = x *. 2 ** nand0.5 <= x < 1.0.
val float : int -> floatSame as
Stdlib.float_of_int.
val truncate : float -> intSame as
Stdlib.int_of_float.
val int_of_float : float -> intTruncate the given floating-point number to an integer. The result is unspecified if the argument is
nanor falls outside the range of representable integers.
val nan : floatA special floating-point value denoting the result of an undefined operation such as
0.0 /. 0.0. Stands for 'not a number'. Any floating-point operation withnanas argument returnsnanas result. As for floating-point comparisons,=,<,<=,>and>=returnfalseand<>returnstrueif one or both of their arguments isnan.
val epsilon_float : floatThe difference between
1.0and the smallest exactly representable floating-point number greater than1.0.
type fpclass= Stdlib.fpclass=The five classes of floating-point numbers, as determined by the
Stdlib.classify_floatfunction.
val classify_float : float -> fpclassReturn the class of the given floating-point number: normal, subnormal, zero, infinite, or not a number.
String operations
More string operations are provided in module String.
Character operations
More character operations are provided in module Char.
Unit operations
String conversion functions
val string_of_bool : bool -> stringReturn the string representation of a boolean. As the returned values may be shared, the user should not modify them directly.
val bool_of_string_opt : string -> bool optionConvert the given string to a boolean.
Return
Noneif the string is not"true"or"false".- since
- 4.05
val bool_of_string : string -> boolSame as
Stdlib.bool_of_string_opt, but raiseInvalid_argument "bool_of_string"instead of returningNone.
val int_of_string_opt : string -> int optionConvert the given string to an integer. The string is read in decimal (by default, or if the string begins with
0u), in hexadecimal (if it begins with0xor0X), in octal (if it begins with0oor0O), or in binary (if it begins with0bor0B).The
0uprefix reads the input as an unsigned integer in the range[0, 2*max_int+1]. If the input exceedsmax_intit is converted to the signed integermin_int + input - max_int - 1.The
_(underscore) character can appear anywhere in the string and is ignored.Return
Noneif the given string is not a valid representation of an integer, or if the integer represented exceeds the range of integers representable in typeint.- since
- 4.05
val int_of_string : string -> intSame as
Stdlib.int_of_string_opt, but raiseFailure "int_of_string"instead of returningNone.
val float_of_string_opt : string -> float optionConvert the given string to a float. The string is read in decimal (by default) or in hexadecimal (marked by
0xor0X).The format of decimal floating-point numbers is
[-] dd.ddd (e|E) [+|-] dd, wheredstands for a decimal digit.The format of hexadecimal floating-point numbers is
[-] 0(x|X) hh.hhh (p|P) [+|-] dd, wherehstands for an hexadecimal digit anddfor a decimal digit.In both cases, at least one of the integer and fractional parts must be given; the exponent part is optional.
The
_(underscore) character can appear anywhere in the string and is ignored.Depending on the execution platforms, other representations of floating-point numbers can be accepted, but should not be relied upon.
Return
Noneif the given string is not a valid representation of a float.- since
- 4.05
val float_of_string : string -> floatSame as
Stdlib.float_of_string_opt, but raiseFailure "float_of_string"instead of returningNone.
Pair operations
List operations
More list operations are provided in module List.
Input/output
Note: all input/output functions can raise Sys_error when the system calls they invoke fail.
type in_channel= Stdlib.in_channelThe type of input channel.
type out_channel= Stdlib.out_channelThe type of output channel.
val stdin : in_channelThe standard input for the process.
val stdout : out_channelThe standard output for the process.
val stderr : out_channelThe standard error output for the process.
Output functions on standard output
Output functions on standard error
Input functions on standard input
val read_line : unit -> stringFlush standard output, then read characters from standard input until a newline character is encountered. Return the string of all characters read, without the newline character at the end.
val read_int_opt : unit -> int optionFlush standard output, then read one line from standard input and convert it to an integer.
Return
Noneif the line read is not a valid representation of an integer.- since
- 4.05
val read_int : unit -> intSame as
Stdlib.read_int_opt, but raiseFailure "int_of_string"instead of returningNone.
val read_float_opt : unit -> float optionFlush standard output, then read one line from standard input and convert it to a floating-point number.
Return
Noneif the line read is not a valid representation of a floating-point number.- since
- 4.05.0
val read_float : unit -> floatSame as
Stdlib.read_float_opt, but raiseFailure "float_of_string"instead of returningNone.
General output functions
type open_flag= Stdlib.open_flag=Opening modes for
Stdlib.open_out_genandStdlib.open_in_gen.
val open_out : string -> out_channelOpen the named file for writing, and return a new output channel on that file, positioned at the beginning of the file. The file is truncated to zero length if it already exists. It is created if it does not already exists.
val open_out_bin : string -> out_channelSame as
Stdlib.open_out, but the file is opened in binary mode, so that no translation takes place during writes. On operating systems that do not distinguish between text mode and binary mode, this function behaves likeStdlib.open_out.
val open_out_gen : open_flag list -> int -> string -> out_channelopen_out_gen mode perm filenameopens the named file for writing, as described above. The extra argumentmodespecifies the opening mode. The extra argumentpermspecifies the file permissions, in case the file must be created.Stdlib.open_outandStdlib.open_out_binare special cases of this function.
val flush : out_channel -> unitFlush the buffer associated with the given output channel, performing all pending writes on that channel. Interactive programs must be careful about flushing standard output and standard error at the right time.
val output_char : out_channel -> char -> unitWrite the character on the given output channel.
val output_string : out_channel -> string -> unitWrite the string on the given output channel.
val output_bytes : out_channel -> bytes -> unitWrite the byte sequence on the given output channel.
- since
- 4.02.0
val output : out_channel -> bytes -> int -> int -> unitoutput oc buf pos lenwriteslencharacters from byte sequencebuf, starting at offsetpos, to the given output channeloc. RaiseInvalid_argument "output"ifposandlendo not designate a valid range ofbuf.
val output_substring : out_channel -> string -> int -> int -> unitSame as
outputbut take a string as argument instead of a byte sequence.- since
- 4.02.0
val output_byte : out_channel -> int -> unitWrite one 8-bit integer (as the single character with that code) on the given output channel. The given integer is taken modulo 256.
val output_binary_int : out_channel -> int -> unitWrite one integer in binary format (4 bytes, big-endian) on the given output channel. The given integer is taken modulo 232. The only reliable way to read it back is through the
Stdlib.input_binary_intfunction. The format is compatible across all machines for a given version of OCaml.
val output_value : out_channel -> 'a -> unitWrite the representation of a structured value of any type to a channel. Circularities and sharing inside the value are detected and preserved. The object can be read back, by the function
Stdlib.input_value. See the description of moduleMarshalfor more information.Stdlib.output_valueis equivalent toMarshal.to_channelwith an empty list of flags.
val seek_out : out_channel -> int -> unitseek_out chan possets the current writing position toposfor channelchan. This works only for regular files. On files of other kinds (such as terminals, pipes and sockets), the behavior is unspecified.
val pos_out : out_channel -> intReturn the current writing position for the given channel. Does not work on channels opened with the
Open_appendflag (returns unspecified results).
val out_channel_length : out_channel -> intReturn the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless.
val close_out : out_channel -> unitClose the given channel, flushing all buffered write operations. Output functions raise a
Sys_errorexception when they are applied to a closed output channel, exceptclose_outandflush, which do nothing when applied to an already closed channel. Note thatclose_outmay raiseSys_errorif the operating system signals an error when flushing or closing.
val close_out_noerr : out_channel -> unitSame as
close_out, but ignore all errors.
val set_binary_mode_out : out_channel -> bool -> unitset_binary_mode_out oc truesets the channelocto binary mode: no translations take place during output.set_binary_mode_out oc falsesets the channelocto text mode: depending on the operating system, some translations may take place during output. For instance, under Windows, end-of-lines will be translated from\nto\r\n. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
General input functions
val open_in : string -> in_channelOpen the named file for reading, and return a new input channel on that file, positioned at the beginning of the file.
val open_in_bin : string -> in_channelSame as
Stdlib.open_in, but the file is opened in binary mode, so that no translation takes place during reads. On operating systems that do not distinguish between text mode and binary mode, this function behaves likeStdlib.open_in.
val open_in_gen : open_flag list -> int -> string -> in_channelopen_in_gen mode perm filenameopens the named file for reading, as described above. The extra argumentsmodeandpermspecify the opening mode and file permissions.Stdlib.open_inandStdlib.open_in_binare special cases of this function.
val input_char : in_channel -> charRead one character from the given input channel. Raise
End_of_fileif there are no more characters to read.
val input_line : in_channel -> stringRead characters from the given input channel, until a newline character is encountered. Return the string of all characters read, without the newline character at the end. Raise
End_of_fileif the end of the file is reached at the beginning of line.
val input : in_channel -> bytes -> int -> int -> intinput ic buf pos lenreads up tolencharacters from the given channelic, storing them in byte sequencebuf, starting at character numberpos. It returns the actual number of characters read, between 0 andlen(inclusive). A return value of 0 means that the end of file was reached. A return value between 0 andlenexclusive means that not all requestedlencharacters were read, either because no more characters were available at that time, or because the implementation found it convenient to do a partial read;inputmust be called again to read the remaining characters, if desired. (See alsoStdlib.really_inputfor reading exactlylencharacters.) ExceptionInvalid_argument "input"is raised ifposandlendo not designate a valid range ofbuf.
val really_input : in_channel -> bytes -> int -> int -> unitreally_input ic buf pos lenreadslencharacters from channelic, storing them in byte sequencebuf, starting at character numberpos. RaiseEnd_of_fileif the end of file is reached beforelencharacters have been read. RaiseInvalid_argument "really_input"ifposandlendo not designate a valid range ofbuf.
val really_input_string : in_channel -> int -> stringreally_input_string ic lenreadslencharacters from channelicand returns them in a new string. RaiseEnd_of_fileif the end of file is reached beforelencharacters have been read.- since
- 4.02.0
val input_byte : in_channel -> intSame as
Stdlib.input_char, but return the 8-bit integer representing the character. RaiseEnd_of_fileif an end of file was reached.
val input_binary_int : in_channel -> intRead an integer encoded in binary format (4 bytes, big-endian) from the given input channel. See
Stdlib.output_binary_int. RaiseEnd_of_fileif an end of file was reached while reading the integer.
val input_value : in_channel -> 'aRead the representation of a structured value, as produced by
Stdlib.output_value, and return the corresponding value. This function is identical toMarshal.from_channel; see the description of moduleMarshalfor more information, in particular concerning the lack of type safety.
val seek_in : in_channel -> int -> unitseek_in chan possets the current reading position toposfor channelchan. This works only for regular files. On files of other kinds, the behavior is unspecified.
val pos_in : in_channel -> intReturn the current reading position for the given channel.
val in_channel_length : in_channel -> intReturn the size (number of characters) of the regular file on which the given channel is opened. If the channel is opened on a file that is not a regular file, the result is meaningless. The returned size does not take into account the end-of-line translations that can be performed when reading from a channel opened in text mode.
val close_in : in_channel -> unitClose the given channel. Input functions raise a
Sys_errorexception when they are applied to a closed input channel, exceptclose_in, which does nothing when applied to an already closed channel.
val close_in_noerr : in_channel -> unitSame as
close_in, but ignore all errors.
val set_binary_mode_in : in_channel -> bool -> unitset_binary_mode_in ic truesets the channelicto binary mode: no translations take place during input.set_binary_mode_out ic falsesets the channelicto text mode: depending on the operating system, some translations may take place during input. For instance, under Windows, end-of-lines will be translated from\r\nto\n. This function has no effect under operating systems that do not distinguish between text mode and binary mode.
Operations on large files
module LargeFile : sig ... endOperations on large files. This sub-module provides 64-bit variants of the channel functions that manipulate file positions and file sizes. By representing positions and sizes by 64-bit integers (type
int64) instead of regular integers (typeint), these alternate functions allow operating on files whose sizes are greater thanmax_int.
References
type 'a ref= 'a Stdlib.ref={mutable contents : 'a;}The type of references (mutable indirection cells) containing a value of type
'a.
val ref : 'a -> 'a refReturn a fresh reference containing the given value.
val (!) : 'a ref -> 'a!rreturns the current contents of referencer. Equivalent tofun r -> r.contents. Unary operator, seeOcaml_operatorsfor more information.
val (:=) : 'a ref -> 'a -> unitr := astores the value ofain referencer. Equivalent tofun r v -> r.contents <- v. Right-associative operator, seeOcaml_operatorsfor more information.
val incr : int ref -> unitIncrement the integer contained in the given reference. Equivalent to
fun r -> r := succ !r.
val decr : int ref -> unitDecrement the integer contained in the given reference. Equivalent to
fun r -> r := pred !r.
Result type
type ('a, 'b) result= ('a, 'b) Stdlib.result=|Ok of 'a|Error of 'b- since
- 4.03.0
Operations on format strings
type ('a, 'b, 'c, 'd, 'e, 'f) format6= ('a, 'b, 'c, 'd, 'e, 'f) CamlinternalFormatBasics.format6type ('a, 'b, 'c, 'd) format4= ('a, 'b, 'c, 'c, 'c, 'd) format6type ('a, 'b, 'c) format= ('a, 'b, 'c, 'c) format4
val string_of_format : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> stringConverts a format string into a string.
val format_of_string : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('a, 'b, 'c, 'd, 'e, 'f) format6format_of_string sreturns a format string read from the string literals. Note:format_of_stringcan not convert a string argument that is not a literal. If you need this functionality, use the more generalScanf.format_from_stringfunction.
val (^^) : ('a, 'b, 'c, 'd, 'e, 'f) format6 -> ('f, 'b, 'c, 'e, 'g, 'h) format6 -> ('a, 'b, 'c, 'd, 'g, 'h) format6f1 ^^ f2catenates format stringsf1andf2. The result is a format string that behaves as the concatenation of format stringsf1andf2: in case of formatted output, it accepts arguments fromf1, then arguments fromf2; in case of formatted input, it returns results fromf1, then results fromf2. Right-associative operator, seeOcaml_operatorsfor more information.
Program termination
val exit : int -> 'aTerminate the process, returning the given status code to the operating system: usually 0 to indicate no errors, and a small positive integer to indicate failure. All open output channels are flushed with
flush_all. An implicitexit 0is performed each time a program terminates normally. An implicitexit 2is performed if the program terminates early because of an uncaught exception.
val at_exit : (unit -> unit) -> unitRegister the given function to be called at program termination time. The functions registered with
at_exitwill be called when the program does any of the following:- executes
Stdlib.exit - terminates, either normally or because of an uncaught exception
- executes the C function
caml_shutdown. The functions are called in 'last in, first out' order: the function most recently added withat_exitis called first.
- executes
Standard library modules
module Arg = Stdlib__arg
module Array = Stdlib__array
module ArrayLabels = Stdlib__arrayLabels
module Bigarray = Stdlib__bigarray
module Bool = Stdlib__bool
module Buffer = Stdlib__buffer
module Bytes = Stdlib__bytes
module BytesLabels = Stdlib__bytesLabels
module Callback = Stdlib__callback
module Char = Stdlib__char
module Complex = Stdlib__complex
module Digest = Stdlib__digest
module Ephemeron = Stdlib__ephemeron
module Filename = Stdlib__filename
module Float = Stdlib__float
module Format = Stdlib__format
module Fun = Stdlib__fun
module Gc = Stdlib__gc
module Genlex = Stdlib__genlex
module Hashtbl = Stdlib__hashtbl
module Int = Stdlib__int
module Int32 = Stdlib__int32
module Int64 = Stdlib__int64
module Lazy = Stdlib__lazy
module Lexing = Stdlib__lexing
module List = Stdlib__list
module ListLabels = Stdlib__listLabels
module Map = Stdlib__map
module Marshal = Stdlib__marshal
module MoreLabels = Stdlib__moreLabels
module Nativeint = Stdlib__nativeint
module Obj = Stdlib__obj
module Oo = Stdlib__oo
module Option = Stdlib__option
module Parsing = Stdlib__parsing
module Pervasives = Stdlib__pervasives
module Printexc = Stdlib__printexc
module Printf = Stdlib__printf
module Queue = Stdlib__queue
module Random = Stdlib__random
module Result = Stdlib__result
module Scanf = Stdlib__scanf
module Seq = Stdlib__seq
module Set = Stdlib__set
module Spacetime = Stdlib__spacetime
module Stack = Stdlib__stack
module StdLabels = Stdlib__stdLabels
module Stream = Stdlib__stream
module String = Stdlib__string
module StringLabels = Stdlib__stringLabels
module Sys = Stdlib__sys
module Uchar = Stdlib__uchar
module Unit = Stdlib__unit
module Weak = Stdlib__weak