Protocol environment / Pervasives: update to 4.06.1

This commit is contained in:
bruno 2018-06-19 17:28:54 +02:00 committed by Benjamin Canou
parent 2af0cb6b75
commit 3ae114f1c9

View File

@ -15,7 +15,7 @@
(* TEZOS CHANGES (* TEZOS CHANGES
* Import version 4.04.0 * Import version 4.06.1
* Remove [channel], [exit], ... * Remove [channel], [exit], ...
* Remove polymorphic comparisons * Remove polymorphic comparisons
* Remove non IEEE754-standardized functions on floats * Remove non IEEE754-standardized functions on floats
@ -36,7 +36,7 @@
*) *)
(** {6 Exceptions} *) (** {1 Exceptions} *)
external raise : exn -> 'a = "%raise" external raise : exn -> 'a = "%raise"
(** Raise the given exception value *) (** Raise the given exception value *)
@ -57,7 +57,7 @@ exception Exit
provided for use in your programs. *) provided for use in your programs. *)
(** {6 Boolean operations} *) (** {1 Boolean operations} *)
external not : bool -> bool = "%boolnot" external not : bool -> bool = "%boolnot"
(** The boolean negation. *) (** The boolean negation. *)
@ -65,15 +65,18 @@ external not : bool -> bool = "%boolnot"
external ( && ) : bool -> bool -> bool = "%sequand" external ( && ) : bool -> bool -> bool = "%sequand"
(** The boolean 'and'. Evaluation is sequential, left-to-right: (** The boolean 'and'. Evaluation is sequential, left-to-right:
in [e1 && e2], [e1] is evaluated first, and if it returns [false], in [e1 && e2], [e1] is evaluated first, and if it returns [false],
[e2] is not evaluated at all. *) [e2] is not evaluated at all.
Right-associative operator at precedence level 3/11. *)
external ( || ) : bool -> bool -> bool = "%sequor" external ( || ) : bool -> bool -> bool = "%sequor"
(** The boolean 'or'. Evaluation is sequential, left-to-right: (** The boolean 'or'. Evaluation is sequential, left-to-right:
in [e1 || e2], [e1] is evaluated first, and if it returns [true], in [e1 || e2], [e1] is evaluated first, and if it returns [true],
[e2] is not evaluated at all. *) [e2] is not evaluated at all.
Right-associative operator at precedence level 2/11.
*)
(** {6 Debugging} *) (** {1 Debugging} *)
external __LOC__ : string = "%loc_LOC" external __LOC__ : string = "%loc_LOC"
(** [__LOC__] returns the location at which this expression appears in (** [__LOC__] returns the location at which this expression appears in
@ -134,31 +137,37 @@ external __POS_OF__ : 'a -> (string * int * int * int) * 'a = "%loc_POS"
@since 4.02.0 @since 4.02.0
*) *)
(** {6 Composition operators} *) (** {1 Composition operators} *)
external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply" external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply"
(** Reverse-application operator: [x |> f |> g] is exactly equivalent (** Reverse-application operator: [x |> f |> g] is exactly equivalent
to [g (f (x))]. to [g (f (x))].
Left-associative operator at precedence level 4/11.
@since 4.01 @since 4.01
*) *)
external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply" external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply"
(** Application operator: [g @@ f @@ x] is exactly equivalent to (** Application operator: [g @@ f @@ x] is exactly equivalent to
[g (f (x))]. [g (f (x))].
Right-associative operator at precedence level 5/11.
@since 4.01 @since 4.01
*) *)
(** {6 Integer arithmetic} *) (** {1 Integer arithmetic} *)
(** Integers are 31 bits wide (or 63 bits on 64-bit processors). (** Integers are 31 bits wide (or 63 bits on 64-bit processors).
All operations are taken modulo 2{^31} (or 2{^63}). All operations are taken modulo 2{^31} (or 2{^63}).
They do not fail on overflow. *) They do not fail on overflow. *)
external ( ~- ) : int -> int = "%negint" external ( ~- ) : int -> int = "%negint"
(** Unary negation. You can also write [- e] instead of [~- e]. *) (** Unary negation. You can also write [- e] instead of [~- e].
Unary operator at precedence level 9/11 for [- e]
and 11/11 for [~- e]. *)
external ( ~+ ) : int -> int = "%identity" external ( ~+ ) : int -> int = "%identity"
(** Unary addition. You can also write [+ e] instead of [~+ e]. (** Unary addition. You can also write [+ e] instead of [~+ e].
Unary operator at precedence level 9/11 for [+ e]
and 11/11 for [~+ e].
@since 3.12.0 @since 3.12.0
*) *)
@ -169,13 +178,16 @@ external pred : int -> int = "%predint"
(** [pred x] is [x - 1]. *) (** [pred x] is [x - 1]. *)
external ( + ) : int -> int -> int = "%addint" external ( + ) : int -> int -> int = "%addint"
(** Integer addition. *) (** Integer addition.
Left-associative operator at precedence level 6/11. *)
external ( - ) : int -> int -> int = "%subint" external ( - ) : int -> int -> int = "%subint"
(** Integer subtraction. *) (** Integer subtraction.
Left-associative operator at precedence level 6/11. *)
external ( * ) : int -> int -> int = "%mulint" external ( * ) : int -> int -> int = "%mulint"
(** Integer multiplication. *) (** Integer multiplication.
Left-associative operator at precedence level 7/11. *)
external ( / ) : int -> int -> int = "%divint" external ( / ) : int -> int -> int = "%divint"
(** Integer division. (** Integer division.
@ -183,7 +195,8 @@ external ( / ) : int -> int -> int = "%divint"
Integer division rounds the real quotient of its arguments towards zero. Integer division rounds the real quotient of its arguments towards zero.
More precisely, if [x >= 0] and [y > 0], [x / y] is the greatest integer More precisely, if [x >= 0] and [y > 0], [x / y] is the greatest integer
less than or equal to the real quotient of [x] by [y]. Moreover, less than or equal to the real quotient of [x] by [y]. Moreover,
[(- x) / y = x / (- y) = - (x / y)]. *) [(- x) / y = x / (- y) = - (x / y)].
Left-associative operator at precedence level 7/11. *)
external ( mod ) : int -> int -> int = "%modint" external ( mod ) : int -> int -> int = "%modint"
(** Integer remainder. If [y] is not zero, the result (** Integer remainder. If [y] is not zero, the result
@ -192,7 +205,8 @@ external ( mod ) : int -> int -> int = "%modint"
[abs(x mod y) <= abs(y) - 1]. [abs(x mod y) <= abs(y) - 1].
If [y = 0], [x mod y] raises [Division_by_zero]. If [y = 0], [x mod y] raises [Division_by_zero].
Note that [x mod y] is negative only if [x < 0]. Note that [x mod y] is negative only if [x < 0].
Raise [Division_by_zero] if [y] is zero. *) Raise [Division_by_zero] if [y] is zero.
Left-associative operator at precedence level 7/11. *)
val abs : int -> int val abs : int -> int
(** Return the absolute value of the argument. Note that this may be (** Return the absolute value of the argument. Note that this may be
@ -205,16 +219,19 @@ val min_int : int
(** The smallest representable integer. *) (** The smallest representable integer. *)
(** {7 Bitwise operations} *) (** {2 Bitwise operations} *)
external ( land ) : int -> int -> int = "%andint" external ( land ) : int -> int -> int = "%andint"
(** Bitwise logical and. *) (** Bitwise logical and.
Left-associative operator at precedence level 7/11. *)
external ( lor ) : int -> int -> int = "%orint" external ( lor ) : int -> int -> int = "%orint"
(** Bitwise logical or. *) (** Bitwise logical or.
Left-associative operator at precedence level 7/11. *)
external ( lxor ) : int -> int -> int = "%xorint" external ( lxor ) : int -> int -> int = "%xorint"
(** Bitwise logical exclusive or. *) (** Bitwise logical exclusive or.
Left-associative operator at precedence level 7/11. *)
val lnot : int -> int val lnot : int -> int
(** Bitwise logical negation. *) (** Bitwise logical negation. *)
@ -223,21 +240,24 @@ external ( lsl ) : int -> int -> int = "%lslint"
(** [n lsl m] shifts [n] to the left by [m] bits. (** [n lsl m] shifts [n] to the left by [m] bits.
The result is unspecified if [m < 0] or [m >= bitsize], The result is unspecified if [m < 0] or [m >= bitsize],
where [bitsize] is [32] on a 32-bit platform and where [bitsize] is [32] on a 32-bit platform and
[64] on a 64-bit platform. *) [64] on a 64-bit platform.
Right-associative operator at precedence level 8/11. *)
external ( lsr ) : int -> int -> int = "%lsrint" external ( lsr ) : int -> int -> int = "%lsrint"
(** [n lsr m] shifts [n] to the right by [m] bits. (** [n lsr m] shifts [n] to the right by [m] bits.
This is a logical shift: zeroes are inserted regardless of This is a logical shift: zeroes are inserted regardless of
the sign of [n]. the sign of [n].
The result is unspecified if [m < 0] or [m >= bitsize]. *) The result is unspecified if [m < 0] or [m >= bitsize].
Right-associative operator at precedence level 8/11. *)
external ( asr ) : int -> int -> int = "%asrint" external ( asr ) : int -> int -> int = "%asrint"
(** [n asr m] shifts [n] to the right by [m] bits. (** [n asr m] shifts [n] to the right by [m] bits.
This is an arithmetic shift: the sign bit of [n] is replicated. This is an arithmetic shift: the sign bit of [n] is replicated.
The result is unspecified if [m < 0] or [m >= bitsize]. *) The result is unspecified if [m < 0] or [m >= bitsize].
Right-associative operator at precedence level 8/11. *)
(** {6 Floating-point arithmetic} (** {1 Floating-point arithmetic}
OCaml's floating-point numbers follow the OCaml's floating-point numbers follow the
IEEE 754 standard, using double precision (64 bits) numbers. IEEE 754 standard, using double precision (64 bits) numbers.
@ -252,24 +272,32 @@ external ( asr ) : int -> int -> int = "%asrint"
*) *)
external ( ~-. ) : float -> float = "%negfloat" external ( ~-. ) : float -> float = "%negfloat"
(** Unary negation. You can also write [-. e] instead of [~-. e]. *) (** Unary negation. You can also write [-. e] instead of [~-. e].
Unary operator at precedence level 9/11 for [-. e]
and 11/11 for [~-. e]. *)
external ( ~+. ) : float -> float = "%identity" external ( ~+. ) : float -> float = "%identity"
(** Unary addition. You can also write [+. e] instead of [~+. e]. (** Unary addition. You can also write [+. e] instead of [~+. e].
Unary operator at precedence level 9/11 for [+. e]
and 11/11 for [~+. e].
@since 3.12.0 @since 3.12.0
*) *)
external ( +. ) : float -> float -> float = "%addfloat" external ( +. ) : float -> float -> float = "%addfloat"
(** Floating-point addition *) (** Floating-point addition.
Left-associative operator at precedence level 6/11. *)
external ( -. ) : float -> float -> float = "%subfloat" external ( -. ) : float -> float -> float = "%subfloat"
(** Floating-point subtraction *) (** Floating-point subtraction.
Left-associative operator at precedence level 6/11. *)
external ( *. ) : float -> float -> float = "%mulfloat" external ( *. ) : float -> float -> float = "%mulfloat"
(** Floating-point multiplication *) (** Floating-point multiplication.
Left-associative operator at precedence level 7/11. *)
external ( /. ) : float -> float -> float = "%divfloat" external ( /. ) : float -> float -> float = "%divfloat"
(** Floating-point division. *) (** Floating-point division.
Left-associative operator at precedence level 7/11. *)
external ceil : float -> float = "caml_ceil_float" "ceil" external ceil : float -> float = "caml_ceil_float" "ceil"
[@@unboxed] [@@noalloc] [@@unboxed] [@@noalloc]
@ -371,16 +399,17 @@ external classify_float : (float [@unboxed]) -> fpclass =
normal, subnormal, zero, infinite, or not a number. *) normal, subnormal, zero, infinite, or not a number. *)
(** {6 String operations} (** {1 String operations}
More string operations are provided in module {!String}. More string operations are provided in module {!String}.
*) *)
val ( ^ ) : string -> string -> string val ( ^ ) : string -> string -> string
(** String concatenation. *) (** String concatenation.
Right-associative operator at precedence level 5/11. *)
(** {6 Character operations} (** {1 Character operations}
More character operations are provided in module {!Char}. More character operations are provided in module {!Char}.
*) *)
@ -394,7 +423,7 @@ val char_of_int : int -> char
outside the range 0--255. *) outside the range 0--255. *)
(** {6 Unit operations} *) (** {1 Unit operations} *)
external ignore : 'a -> unit = "%ignore" external ignore : 'a -> unit = "%ignore"
(** Discard the value of its argument and return [()]. (** Discard the value of its argument and return [()].
@ -405,7 +434,7 @@ external ignore : 'a -> unit = "%ignore"
avoids the warning. *) avoids the warning. *)
(** {6 String conversion functions} *) (** {1 String conversion functions} *)
val string_of_bool : bool -> string val string_of_bool : bool -> string
(** Return the string representation of a boolean. As the returned values (** Return the string representation of a boolean. As the returned values
@ -417,20 +446,40 @@ val bool_of_string : string -> bool
Raise [Invalid_argument "bool_of_string"] if the string is not Raise [Invalid_argument "bool_of_string"] if the string is not
["true"] or ["false"]. *) ["true"] or ["false"]. *)
val bool_of_string_opt: string -> bool option
(** Convert the given string to a boolean.
Return [None] if the string is not
["true"] or ["false"].
@since 4.05
*)
val string_of_int : int -> string val string_of_int : int -> string
(** Return the string representation of an integer, in decimal. *) (** Return the string representation of an integer, in decimal. *)
external int_of_string : string -> int = "caml_int_of_string" external int_of_string : string -> int = "caml_int_of_string"
(** Convert the given string to an integer. (** Convert the given string to an integer.
The string is read in decimal (by default), in hexadecimal (if it The string is read in decimal (by default, or if the string
begins with [0x] or [0X]), in octal (if it begins with [0o] or [0O]), begins with [0u]), in hexadecimal (if it begins with [0x] or
or in binary (if it begins with [0b] or [0B]). [0X]), in octal (if it begins with [0o] or [0O]), or in binary
(if it begins with [0b] or [0B]).
The [0u] prefix reads the input as an unsigned integer in the range
[[0, 2*max_int+1]]. If the input exceeds {!max_int}
it is converted to the signed integer
[min_int + input - max_int - 1].
The [_] (underscore) character can appear anywhere in the string The [_] (underscore) character can appear anywhere in the string
and is ignored. and is ignored.
Raise [Failure "int_of_string"] if the given string is not Raise [Failure "int_of_string"] if the given string is not
a valid representation of an integer, or if the integer represented a valid representation of an integer, or if the integer represented
exceeds the range of integers representable in type [int]. *) exceeds the range of integers representable in type [int]. *)
val int_of_string_opt: string -> int option
(** Same as [int_of_string], but returns [None] instead of raising.
@since 4.05
*)
val string_of_float : float -> string val string_of_float : float -> string
(** Return the string representation of a floating-point number. *) (** Return the string representation of a floating-point number. *)
@ -451,7 +500,12 @@ external float_of_string : string -> float = "caml_float_of_string"
Raise [Failure "float_of_string"] if the given string is not a valid Raise [Failure "float_of_string"] if the given string is not a valid
representation of a float. *) representation of a float. *)
(** {6 Pair operations} *) val float_of_string_opt: string -> float option
(** Same as [float_of_string], but returns [None] instead of raising.
@since 4.05
*)
(** {1 Pair operations} *)
external fst : 'a * 'b -> 'a = "%field0" external fst : 'a * 'b -> 'a = "%field0"
(** Return the first component of a pair. *) (** Return the first component of a pair. *)
@ -460,16 +514,17 @@ external snd : 'a * 'b -> 'b = "%field1"
(** Return the second component of a pair. *) (** Return the second component of a pair. *)
(** {6 List operations} (** {1 List operations}
More list operations are provided in module {!List}. More list operations are provided in module {!List}.
*) *)
val ( @ ) : 'a list -> 'a list -> 'a list val ( @ ) : 'a list -> 'a list -> 'a list
(** List concatenation. Not tail-recursive (length of the first argument). *) (** List concatenation. Not tail-recursive (length of the first argument).
Right-associative operator at precedence level 5/11. *)
(** {6 References} *) (** {1 References} *)
type 'a ref = { mutable contents : 'a } type 'a ref = { mutable contents : 'a }
(** The type of references (mutable indirection cells) containing (** The type of references (mutable indirection cells) containing
@ -480,11 +535,13 @@ external ref : 'a -> 'a ref = "%makemutable"
external ( ! ) : 'a ref -> 'a = "%field0" external ( ! ) : 'a ref -> 'a = "%field0"
(** [!r] returns the current contents of reference [r]. (** [!r] returns the current contents of reference [r].
Equivalent to [fun r -> r.contents]. *) Equivalent to [fun r -> r.contents].
Unary operator at precedence level 11/11.*)
external ( := ) : 'a ref -> 'a -> unit = "%setfield0" external ( := ) : 'a ref -> 'a -> unit = "%setfield0"
(** [r := a] stores the value of [a] in reference [r]. (** [r := a] stores the value of [a] in reference [r].
Equivalent to [fun r v -> r.contents <- v]. *) Equivalent to [fun r v -> r.contents <- v].
Right-associative operator at precedence level 1/11. *)
external incr : int ref -> unit = "%incr" external incr : int ref -> unit = "%incr"
(** Increment the integer contained in the given reference. (** Increment the integer contained in the given reference.
@ -494,11 +551,12 @@ external decr : int ref -> unit = "%decr"
(** Decrement the integer contained in the given reference. (** Decrement the integer contained in the given reference.
Equivalent to [fun r -> r := pred !r]. *) Equivalent to [fun r -> r := pred !r]. *)
(** {6 Result type} *) (** {1 Result type} *)
(** @since 4.03.0 *)
type ('a,'b) result = Ok of 'a | Error of 'b type ('a,'b) result = Ok of 'a | Error of 'b
(** {6 Operations on format strings} *) (** {1 Operations on format strings} *)
(** Format strings are character strings with special lexical conventions (** Format strings are character strings with special lexical conventions
that defines the functionality of formatted input/output functions. Format that defines the functionality of formatted input/output functions. Format
@ -542,12 +600,12 @@ type ('a,'b) result = Ok of 'a | Error of 'b
- ['b] is the type of input source for formatted input functions and the - ['b] is the type of input source for formatted input functions and the
type of output target for formatted output functions. type of output target for formatted output functions.
For [printf]-style functions from module [Printf], ['b] is typically For [printf]-style functions from module {!Printf}, ['b] is typically
[out_channel]; [out_channel];
for [printf]-style functions from module [Format], ['b] is typically for [printf]-style functions from module {!Format}, ['b] is typically
[Format.formatter]; {!Format.formatter};
for [scanf]-style functions from module [Scanf], ['b] is typically for [scanf]-style functions from module {!Scanf}, ['b] is typically
[Scanf.Scanning.in_channel]. {!Scanf.Scanning.in_channel}.
Type argument ['b] is also the type of the first argument given to Type argument ['b] is also the type of the first argument given to
user's defined printing functions for [%a] and [%t] conversions, user's defined printing functions for [%a] and [%t] conversions,
@ -597,5 +655,4 @@ val ( ^^ ) :
[f2]: in case of formatted output, it accepts arguments from [f1], then [f2]: in case of formatted output, it accepts arguments from [f1], then
arguments from [f2]; in case of formatted input, it returns results from arguments from [f2]; in case of formatted input, it returns results from
[f1], then results from [f2]. [f1], then results from [f2].
*) Right-associative operator at precedence level 5/11. *)