diff --git a/src/lib_protocol_environment/sigs/v1/pervasives.mli b/src/lib_protocol_environment/sigs/v1/pervasives.mli index b61cd7dc1..6e39888d4 100644 --- a/src/lib_protocol_environment/sigs/v1/pervasives.mli +++ b/src/lib_protocol_environment/sigs/v1/pervasives.mli @@ -15,7 +15,7 @@ (* TEZOS CHANGES - * Import version 4.04.0 + * Import version 4.06.1 * Remove [channel], [exit], ... * Remove polymorphic comparisons * Remove non IEEE754-standardized functions on floats @@ -36,7 +36,7 @@ *) -(** {6 Exceptions} *) +(** {1 Exceptions} *) external raise : exn -> 'a = "%raise" (** Raise the given exception value *) @@ -57,7 +57,7 @@ exception Exit provided for use in your programs. *) -(** {6 Boolean operations} *) +(** {1 Boolean operations} *) external not : bool -> bool = "%boolnot" (** The boolean negation. *) @@ -65,15 +65,18 @@ external not : bool -> bool = "%boolnot" external ( && ) : bool -> bool -> bool = "%sequand" (** The boolean 'and'. Evaluation is sequential, left-to-right: 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" (** The boolean 'or'. Evaluation is sequential, left-to-right: 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" (** [__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 *) -(** {6 Composition operators} *) +(** {1 Composition operators} *) external ( |> ) : 'a -> ('a -> 'b) -> 'b = "%revapply" (** Reverse-application operator: [x |> f |> g] is exactly equivalent to [g (f (x))]. + Left-associative operator at precedence level 4/11. @since 4.01 *) external ( @@ ) : ('a -> 'b) -> 'a -> 'b = "%apply" (** Application operator: [g @@ f @@ x] is exactly equivalent to [g (f (x))]. + Right-associative operator at precedence level 5/11. @since 4.01 *) -(** {6 Integer arithmetic} *) +(** {1 Integer arithmetic} *) (** Integers are 31 bits wide (or 63 bits on 64-bit processors). All operations are taken modulo 2{^31} (or 2{^63}). They do not fail on overflow. *) 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" (** 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 *) @@ -169,13 +178,16 @@ external pred : int -> int = "%predint" (** [pred x] is [x - 1]. *) external ( + ) : int -> int -> int = "%addint" -(** Integer addition. *) +(** Integer addition. + Left-associative operator at precedence level 6/11. *) external ( - ) : int -> int -> int = "%subint" -(** Integer subtraction. *) +(** Integer subtraction. + Left-associative operator at precedence level 6/11. *) external ( * ) : int -> int -> int = "%mulint" -(** Integer multiplication. *) +(** Integer multiplication. + Left-associative operator at precedence level 7/11. *) external ( / ) : int -> int -> int = "%divint" (** Integer division. @@ -183,7 +195,8 @@ external ( / ) : int -> int -> int = "%divint" 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 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" (** 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]. If [y = 0], [x mod y] raises [Division_by_zero]. 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 (** Return the absolute value of the argument. Note that this may be @@ -205,16 +219,19 @@ val min_int : int (** The smallest representable integer. *) -(** {7 Bitwise operations} *) +(** {2 Bitwise operations} *) 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" -(** Bitwise logical or. *) +(** Bitwise logical or. + Left-associative operator at precedence level 7/11. *) 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 (** Bitwise logical negation. *) @@ -223,21 +240,24 @@ external ( lsl ) : int -> int -> int = "%lslint" (** [n lsl m] shifts [n] to the left by [m] bits. The result is unspecified if [m < 0] or [m >= bitsize], 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" (** [n lsr m] shifts [n] to the right by [m] bits. This is a logical shift: zeroes are inserted regardless of 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" (** [n asr m] shifts [n] to the right by [m] bits. 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 IEEE 754 standard, using double precision (64 bits) numbers. @@ -252,24 +272,32 @@ external ( asr ) : int -> int -> int = "%asrint" *) 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" (** 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 *) external ( +. ) : float -> float -> float = "%addfloat" -(** Floating-point addition *) +(** Floating-point addition. + Left-associative operator at precedence level 6/11. *) external ( -. ) : float -> float -> float = "%subfloat" -(** Floating-point subtraction *) +(** Floating-point subtraction. + Left-associative operator at precedence level 6/11. *) external ( *. ) : float -> float -> float = "%mulfloat" -(** Floating-point multiplication *) +(** Floating-point multiplication. + Left-associative operator at precedence level 7/11. *) 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" [@@unboxed] [@@noalloc] @@ -371,16 +399,17 @@ external classify_float : (float [@unboxed]) -> fpclass = normal, subnormal, zero, infinite, or not a number. *) -(** {6 String operations} +(** {1 String operations} More string operations are provided in module {!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}. *) @@ -394,7 +423,7 @@ val char_of_int : int -> char outside the range 0--255. *) -(** {6 Unit operations} *) +(** {1 Unit operations} *) external ignore : 'a -> unit = "%ignore" (** Discard the value of its argument and return [()]. @@ -405,7 +434,7 @@ external ignore : 'a -> unit = "%ignore" avoids the warning. *) -(** {6 String conversion functions} *) +(** {1 String conversion functions} *) val string_of_bool : bool -> string (** 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 ["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 (** Return the string representation of an integer, in decimal. *) external int_of_string : string -> int = "caml_int_of_string" (** Convert the given string to an integer. - The string is read in decimal (by default), in hexadecimal (if it - begins with [0x] or [0X]), in octal (if it begins with [0o] or [0O]), - or in binary (if it begins with [0b] or [0B]). + The string is read in decimal (by default, or if the string + begins with [0u]), in hexadecimal (if it begins with [0x] or + [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 and is ignored. Raise [Failure "int_of_string"] if the given string is not a valid representation of an integer, or if the integer represented 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 (** 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 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" (** Return the first component of a pair. *) @@ -460,16 +514,17 @@ external snd : 'a * 'b -> 'b = "%field1" (** Return the second component of a pair. *) -(** {6 List operations} +(** {1 List operations} More list operations are provided in module {!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 } (** The type of references (mutable indirection cells) containing @@ -480,11 +535,13 @@ external ref : 'a -> 'a ref = "%makemutable" external ( ! ) : 'a ref -> 'a = "%field0" (** [!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" (** [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" (** 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. 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 -(** {6 Operations on format strings} *) +(** {1 Operations on format strings} *) (** Format strings are character strings with special lexical conventions 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 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]; - for [printf]-style functions from module [Format], ['b] is typically - [Format.formatter]; - for [scanf]-style functions from module [Scanf], ['b] is typically - [Scanf.Scanning.in_channel]. + for [printf]-style functions from module {!Format}, ['b] is typically + {!Format.formatter}; + for [scanf]-style functions from module {!Scanf}, ['b] is typically + {!Scanf.Scanning.in_channel}. Type argument ['b] is also the type of the first argument given to 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 arguments from [f2]; in case of formatted input, it returns results from [f1], then results from [f2]. -*) - + Right-associative operator at precedence level 5/11. *)