From a5b8a0aa18c21535a3898390ed7d701f2d07e831 Mon Sep 17 00:00:00 2001 From: JPR Date: Mon, 16 Mar 2020 23:25:46 +0100 Subject: [PATCH] Substitute 'Pervasives' with 'Stdlib' --- README.md | 8 ++++---- src/core/CCBool.mli | 2 +- src/core/CCChar.mli | 2 +- src/core/CCFun.mli | 2 +- src/core/CCInt.mli | 2 +- src/core/CCInt32.mli | 4 ++-- src/core/CCInt64.mli | 6 +++--- src/core/CCList.mli | 2 +- src/core/CCListLabels.mli | 2 +- src/core/CCNativeint.mli | 4 ++-- src/iter/CCKList.ml | 2 +- src/monomorphic/CCMonomorphic.mli | 6 +++--- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 42c0a655..e92607ef 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/core/CCBool.mli b/src/core/CCBool.mli index f38e85db..078627c8 100644 --- a/src/core/CCBool.mli +++ b/src/core/CCBool.mli @@ -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. *) diff --git a/src/core/CCChar.mli b/src/core/CCChar.mli index 959959d1..b6135c76 100644 --- a/src/core/CCChar.mli +++ b/src/core/CCChar.mli @@ -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}. *) diff --git a/src/core/CCFun.mli b/src/core/CCFun.mli index e9707d81..9a1f5fa8 100644 --- a/src/core/CCFun.mli +++ b/src/core/CCFun.mli @@ -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 ]} *) diff --git a/src/core/CCInt.mli b/src/core/CCInt.mli index 2f73d7e3..3d3a8622 100644 --- a/src/core/CCInt.mli +++ b/src/core/CCInt.mli @@ -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. *) diff --git a/src/core/CCInt32.mli b/src/core/CCInt32.mli index b355496b..72acc48b 100644 --- a/src/core/CCInt32.mli +++ b/src/core/CCInt32.mli @@ -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} *) diff --git a/src/core/CCInt64.mli b/src/core/CCInt64.mli index 86acdaa7..db2fee87 100644 --- a/src/core/CCInt64.mli +++ b/src/core/CCInt64.mli @@ -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} *) diff --git a/src/core/CCList.mli b/src/core/CCList.mli index 65ae4c67..1760e678 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -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 diff --git a/src/core/CCListLabels.mli b/src/core/CCListLabels.mli index 7152ffa6..63a6874d 100644 --- a/src/core/CCListLabels.mli +++ b/src/core/CCListLabels.mli @@ -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 diff --git a/src/core/CCNativeint.mli b/src/core/CCNativeint.mli index 310b2fe8..f299c0d9 100644 --- a/src/core/CCNativeint.mli +++ b/src/core/CCNativeint.mli @@ -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} *) diff --git a/src/iter/CCKList.ml b/src/iter/CCKList.ml index 28be96a6..e5e4988c 100644 --- a/src/iter/CCKList.ml +++ b/src/iter/CCKList.ml @@ -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} *) diff --git a/src/monomorphic/CCMonomorphic.mli b/src/monomorphic/CCMonomorphic.mli index 6b19e49f..dde2501a 100644 --- a/src/monomorphic/CCMonomorphic.mli +++ b/src/monomorphic/CCMonomorphic.mli @@ -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."]