Substitute 'Pervasives' with 'Stdlib'

This commit is contained in:
JPR 2020-03-16 23:25:46 +01:00 committed by Simon Cruanes
parent 76c1c98bbf
commit a5b8a0aa18
12 changed files with 21 additions and 21 deletions

View file

@ -51,14 +51,14 @@ Some of the modules have been moved to their own repository (e.g. `sequence` (no
- many optional arguments have become mandatory, because their default value
would be a polymorphic "magic" operator such as `(=)` or `(>=)`.
Now these have to be specified explicitly, but during the transition
you can use `Pervasives.(=)` and `Pervasives.(>=)` as explicit arguments.
you can use `Stdlib.(=)` and `Stdlib.(>=)` as explicit arguments.
- if your code contains `open Containers`, the biggest hurdle you face
might be that operators have become monomorphic by default.
We believe this is a useful change that prevents many subtle bugs.
However, during migration and until you use proper combinators for
equality (`CCEqual`), comparison (`CCOrd`), and hashing (`CCHash`),
you might want to add `open Pervasives` just after the `open Containers`.
you might want to add `open Stdlib` just after the `open Containers`.
See [the section on monomorphic operators](#monomorphic-operators-why-and-how) for more details.
## Monomorphic operators: why, and how?
@ -94,9 +94,9 @@ See also:
### Sometimes polymorphic operators still make sense!
If you just want to use polymorphic operators, it's fine! You can access them
easily by using `Pervasives.(=)`, `Pervasives.max`, etc.
easily by using `Stdlib.(=)`, `Stdlib.max`, etc.
When migrating a module, you can add `open Pervasives` on top of it to restore
When migrating a module, you can add `open Stdlib` on top of it to restore
the default behavior. It is, however, recommended to export an `equal` function
(and `compare`, and `hash`) for all the public types, even if their internal
definition is just the corresponding polymorphic operator.

View file

@ -5,7 +5,7 @@
type t = bool
val compare : t -> t -> int
(** [compare b1 b2] is the total ordering on booleans [b1] and [b2], similar to {!Pervasives.compare}. *)
(** [compare b1 b2] is the total ordering on booleans [b1] and [b2], similar to {!Stdlib.compare}. *)
val equal : t -> t -> bool
(** [equal b1 b2] is [true] if [b1] and [b2] are the same. *)

View file

@ -8,7 +8,7 @@ include module type of struct include Char end
val compare : t -> t -> int
(** The comparison function for characters, with the same specification as
{!Pervasives.compare}. Along with the type [t], this function [compare]
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [Char] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)

View file

@ -37,7 +37,7 @@ val tap : ('a -> _) -> 'a -> 'a
in a pipeline, for instance:
{[CCArray.(1 -- 10)
|> tap CCArray.shuffle
|> tap @@ CCArray.sort Pervasives.compare
|> tap @@ CCArray.sort Stdlib.compare
]}
*)

View file

@ -6,7 +6,7 @@
type t = int
val compare : t -> t -> int
(** The comparison function for integers with the same specification as {!Pervasives.compare}. *)
(** The comparison function for integers with the same specification as {!Stdlib.compare}. *)
val equal : t -> t -> bool
(** Equality function for integers. *)

View file

@ -32,7 +32,7 @@ val ( * ) : t -> t -> t
val ( / ) : t -> t -> t
(** Integer division. Raise [Division_by_zero] if the second
argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for {!Pervasives.(/)}. *)
its arguments towards zero, as specified for {!Stdlib.(/)}. *)
val ( mod ) : t -> t -> t
(** [x mod y ] is the integer remainder.
@ -93,7 +93,7 @@ end
include module type of Infix
val hash : t -> int
(** Like {!Pervasives.abs (to_int x)}. *)
(** Like {!Stdlib.abs (to_int x)}. *)
(** {2 Conversion} *)

View file

@ -23,7 +23,7 @@ val ( * ) : t -> t -> t
val (/) : t -> t -> t
(** Integer division. Raise [Division_by_zero] if the second
argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for {!Pervasives.(/)}. *)
its arguments towards zero, as specified for {!Stdlib.(/)}. *)
val (mod) : t -> t -> t
(** Integer remainder.
@ -94,12 +94,12 @@ include module type of Infix
val compare : t -> t -> int
(** The comparison function for 64-bit integers, with the same specification as
{!Pervasives.compare}. Along with the type [t], this function [compare]
{!Stdlib.compare}. Along with the type [t], this function [compare]
allows the module [CCInt64] to be passed as argument to the functors
{!Set.Make} and {!Map.Make}. *)
val hash : t -> int
(** Like {!Pervasives.abs (to_int x)}. *)
(** Like {!Stdlib.abs (to_int x)}. *)
(** {2 Conversion} *)

View file

@ -452,7 +452,7 @@ val sorted_merge_uniq : cmp:('a -> 'a -> int) -> 'a list -> 'a list -> 'a list
val is_sorted : cmp:('a -> 'a -> int) -> 'a list -> bool
(** [is_sorted l] returns [true] iff [l] is sorted (according to given order).
@param cmp the comparison function (default [Pervasives.compare]).
@param cmp the comparison function (default [Stdlib.compare]).
@since 0.17 *)
val sorted_insert : cmp:('a -> 'a -> int) -> ?uniq:bool -> 'a -> 'a list -> 'a list

View file

@ -456,7 +456,7 @@ val sorted_merge_uniq : cmp:(('a -> 'a -> int) [@keep_label]) -> 'a list -> 'a l
val is_sorted : cmp:(('a -> 'a -> int) [@keep_label]) -> 'a list -> bool
(** [is_sorted l] returns [true] iff [l] is sorted (according to given order).
@param cmp the comparison function (default [Pervasives.compare]).
@param cmp the comparison function (default [Stdlib.compare]).
@since 0.17 *)
val sorted_insert : cmp:(('a -> 'a -> int) [@keep_label]) -> ?uniq:bool -> 'a -> 'a list -> 'a list

View file

@ -33,7 +33,7 @@ val ( * ) : t -> t -> t
val ( / ) : t -> t -> t
(** Integer division. Raise [Division_by_zero] if the second
argument is zero. This division rounds the real quotient of
its arguments towards zero, as specified for {!Pervasives.(/)}. *)
its arguments towards zero, as specified for {!Stdlib.(/)}. *)
val ( mod ) : t -> t -> t
(** [x mod y ] is the integer remainder.
@ -94,7 +94,7 @@ module Infix : sig
end
val hash : t -> int
(** Like {!Pervasives.abs (to_int x)}. *)
(** Like {!Stdlib.abs (to_int x)}. *)
(** {2 Conversion} *)

View file

@ -483,7 +483,7 @@ let (<.>) f a = fair_app f a
(*$T
interleave (of_list [1;3;5]) (of_list [2;4;6]) |> to_list = [1;2;3;4;5;6]
fair_app (of_list [(+)1; ( * ) 3]) (of_list [1; 10]) \
|> to_list |> List.sort Pervasives.compare = [2; 3; 11; 30]
|> to_list |> List.sort Stdlib.compare = [2; 3; 11; 30]
*)
(** {2 Infix} *)

View file

@ -1,7 +1,7 @@
(* This file is free software, part of containers. See file "license" for more details. *)
(** {1 Shadow unsafe functions and operators from Pervasives} *)
(** {1 Shadow unsafe functions and operators from Stdlib} *)
(** @since 2.0 *)
val (=) : int -> int -> bool
@ -32,8 +32,8 @@ val (>=.) : float -> float -> bool (** @since 2.1 *)
(** {2 Shadow Dangerous Operators} *)
val (==) : [`Consider_using_CCEqual_physical]
[@@ocaml.deprecated "Please use CCEqual.physical or Pervasives.(==) instead."]
[@@ocaml.deprecated "Please use CCEqual.physical or Stdlib.(==) instead."]
(** @since 2.1 *)
val (!=) : [`Consider_using_CCEqual_physical]
[@@ocaml.deprecated "Please use [not CCEqual.physical] or Pervasives.(!=) instead."]
[@@ocaml.deprecated "Please use [not CCEqual.physical] or Stdlib.(!=) instead."]