From 6f3a7d902aa3979ec9585c88db882d85fd714e9a Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Mon, 21 Feb 2022 21:20:43 -0500 Subject: [PATCH] remove more shims --- src/core/CCArray.ml | 20 +++++++- src/core/CCArray.mli | 27 ++++++++++- src/core/CCArrayLabels.mli | 28 ++++++++++- src/core/CCList.ml | 11 ++++- src/core/CCList.mli | 19 ++++++-- src/core/dune | 5 +- src/core/mkshims.ml | 69 --------------------------- src/core/tests/check_labelled_mods.ml | 2 +- src/monomorphic/CCMonomorphic.ml | 2 +- 9 files changed, 99 insertions(+), 84 deletions(-) diff --git a/src/core/CCArray.ml b/src/core/CCArray.ml index 09a8af01..245d431b 100644 --- a/src/core/CCArray.ml +++ b/src/core/CCArray.ml @@ -16,8 +16,24 @@ type 'a printer = Format.formatter -> 'a -> unit (** {2 Arrays} *) -include CCShims_ -include CCShimsArray_ +open CCShims_ + +[@@@ifge 4.8] + +include Array + +[@@@elifge 4.6] + +include Array +type 'a t = 'a array + +[@@@else_] + +include Array +module Floatarray = struct type t = float array end +type 'a t = 'a array + +[@@@endif] let empty = [| |] diff --git a/src/core/CCArray.mli b/src/core/CCArray.mli index 99590017..9aa126c0 100644 --- a/src/core/CCArray.mli +++ b/src/core/CCArray.mli @@ -14,8 +14,31 @@ type 'a printer = Format.formatter -> 'a -> unit (** {2 Arrays} *) -include module type of CCShimsArray_ -(** @inline *) +[@@@ifge 4.8] + +include module type of Array +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +[@@@elifge 4.6] + +include module type of Array +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +type 'a t = 'a array + +[@@@else_] + +include module type of Array +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +module Floatarray : sig type t = float array end + +type 'a t = 'a array + +[@@@endif] val empty : 'a t (** [empty] is the empty array, physically equal to [[||]]. *) diff --git a/src/core/CCArrayLabels.mli b/src/core/CCArrayLabels.mli index c385c721..4bbedbc7 100644 --- a/src/core/CCArrayLabels.mli +++ b/src/core/CCArrayLabels.mli @@ -14,8 +14,32 @@ type 'a printer = Format.formatter -> 'a -> unit (** {2 Arrays} *) -include module type of CCShimsArrayLabels_ -(** @inline *) +[@@@ifge 4.8] + + +include module type of ArrayLabels with module Floatarray = Array.Floatarray +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +[@@@elifge 4.6] + +include module type of ArrayLabels with module Floatarray = Array.Floatarray +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +type 'a t = 'a array + +[@@@else_] + +include module type of ArrayLabels +(** {{: http://caml.inria.fr/pub/docs/manual-ocaml/libref/ArrayLabels.html} Documentation for the standard ArrayLabels module}*) + +module Floatarray = CCArray.Floatarray +type 'a t = 'a array +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) + +[@@@endif] val empty : 'a t (** [empty] is the empty array, physically equal to [||]. *) diff --git a/src/core/CCList.ml b/src/core/CCList.ml index a371b964..da2d9648 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -66,7 +66,16 @@ let rec assq_opt x = function (* end of backport *) -include CCShimsList_ +[@@@ifge 4.8] + +include List + +[@@@else_] + +include List +type +'a t = 'a list + +[@@@endif] let empty = [] diff --git a/src/core/CCList.mli b/src/core/CCList.mli index 034b8a31..a918bb05 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -11,10 +11,23 @@ type 'a gen = unit -> 'a option type 'a printer = Format.formatter -> 'a -> unit type 'a random_gen = Random.State.t -> 'a -include module type of List -(** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html} Documentation for the standard List module}*) +[@@@ifge 4.8] -type 'a t = 'a list +include module type of List with type 'a t := 'a list +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html} Documentation for the standard List module}*) + +type +'a t = 'a list + +[@@@else_] + +include module type of List +(** @inline + {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/List.html} Documentation for the standard List module}*) + +type +'a t = 'a list + +[@@@endif] val empty : 'a t (** [empty] is [[]]. *) diff --git a/src/core/dune b/src/core/dune index 552b5e69..2d804bf1 100644 --- a/src/core/dune +++ b/src/core/dune @@ -5,9 +5,8 @@ (libraries dune.configurator)) (rule - (targets CCShimsList_.ml - CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsMkLetList_.ml - CCShimsArrayLabels_.ml) + (targets + CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsMkLetList_.ml) (deps ./mkshims.exe) (action (run ./mkshims.exe))) diff --git a/src/core/mkshims.ml b/src/core/mkshims.ml index 33fe608a..1134f9d6 100644 --- a/src/core/mkshims.ml +++ b/src/core/mkshims.ml @@ -34,66 +34,6 @@ let cc_update_funs funs f1 f2 = } " -let shims_fun_pre_408 = " - external id : 'a -> 'a = \"%identity\" - let[@inline] flip f x y = f y x - let[@inline] const x _ = x - let[@inline] negate f x = not (f x) - let[@inline] protect ~finally f = - try - let x= f() in - finally(); - x - with e -> - finally(); - raise e - -" - -let shims_list_pre_408 = " - include List - type +'a t = 'a list -" -let shims_list_post_408 = "include List" - -let shims_array_pre_406 = " - include Array - (** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) - - module Floatarray = struct type t = float array end - type 'a t = 'a array - " - -let shims_array_label_pre_406 = " - include ArrayLabels - (** {{: http://caml.inria.fr/pub/docs/manual-ocaml/libref/ArrayLabels.html} Documentation for the standard ArrayLabels module}*) - - module Floatarray = CCShimsArray_.Floatarray - type 'a t = 'a array - " - -let shims_array_label_406_408 = " - include (ArrayLabels : module type of ArrayLabels with module Floatarray = Array.Floatarray) - (** {{: http://caml.inria.fr/pub/docs/manual-ocaml/libref/ArrayLabels.html} Documentation for the standard ArrayLabels module}*) - - type 'a t = 'a array - " - -let shims_array_406_408 = " - include Array - (** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) - - type 'a t = 'a array -" -let shims_array_post_408 = " - include Array - (** {{: https://caml.inria.fr/pub/docs/manual-ocaml/libref/Array.html} Documentation for the standard Array module}*) -" -let shims_array_label_post_408 = " - include (ArrayLabels : module type of ArrayLabels with module Floatarray = Array.Floatarray) - (** {{: http://caml.inria.fr/pub/docs/manual-ocaml/libref/ArrayLabels.html} Documentation for the standard ArrayLabels module}*) -" - let shims_let_op_pre_408 = " (** glue code for let-operators on OCaml < 4.08 (auto generated) *) @@ -184,15 +124,6 @@ let () = C.main ~name:"mkshims" (fun c -> let version = C.ocaml_config_var_exn c "version" in let major, minor = Scanf.sscanf version "%u.%u" (fun maj min -> maj, min) in - write_file "CCShimsList_.ml" (if (major, minor) >= (4,8) then shims_list_post_408 else shims_list_pre_408); - write_file "CCShimsArray_.ml" - (if (major, minor) >= (4,8) then shims_array_post_408 - else if (major, minor) >= (4,6) then shims_array_406_408 - else shims_array_pre_406); - write_file "CCShimsArrayLabels_.ml" - (if (major, minor) >= (4,8) then shims_array_label_post_408 - else if (major, minor) >= (4,6) then shims_array_label_406_408 - else shims_array_label_pre_406); write_file "CCShimsFormat_.ml" (if (major, minor) >= (4,8) then shims_fmt_post_408 else shims_fmt_pre_408); write_file "CCShimsMkLet_.ml" (if (major, minor) >= (4,8) then shims_let_op_post_408 else shims_let_op_pre_408); write_file "CCShimsMkLetList_.ml" (if (major, minor) >= (4,8) then shims_let_op_list_post_408 else shims_let_op_list_pre_408); diff --git a/src/core/tests/check_labelled_mods.ml b/src/core/tests/check_labelled_mods.ml index 7745095b..05d4dc91 100644 --- a/src/core/tests/check_labelled_mods.ml +++ b/src/core/tests/check_labelled_mods.ml @@ -2,7 +2,7 @@ module A = struct (* test consistency of interfaces *) - module FA = CCShimsArray_.Floatarray + module FA = CCArray.Floatarray module type L = module type of CCArray with module Floatarray := FA module type LL = module type of CCArrayLabels with module Floatarray := FA diff --git a/src/monomorphic/CCMonomorphic.ml b/src/monomorphic/CCMonomorphic.ml index 2810e5c3..14bf732e 100644 --- a/src/monomorphic/CCMonomorphic.ml +++ b/src/monomorphic/CCMonomorphic.ml @@ -1,7 +1,7 @@ (* This file is free software, part of containers. See file "license" for more details. *) -[@@@ifle 4.07] +[@@@ifge 4.07] [@@@else_] module Stdlib = Pervasives [@@@endif]