mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
remove more shims
This commit is contained in:
parent
c32529fd5a
commit
6f3a7d902a
9 changed files with 99 additions and 84 deletions
|
|
@ -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 = [| |]
|
||||
|
||||
|
|
|
|||
|
|
@ -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 [[||]]. *)
|
||||
|
|
|
|||
|
|
@ -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 [||]. *)
|
||||
|
|
|
|||
|
|
@ -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 = []
|
||||
|
||||
|
|
|
|||
|
|
@ -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 [[]]. *)
|
||||
|
|
|
|||
|
|
@ -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)))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue