fix: use shims again for CCList.(and&)

This commit is contained in:
Simon Cruanes 2020-11-13 12:46:59 -05:00
parent 9068cbc1cc
commit ca7801a854
4 changed files with 54 additions and 33 deletions

View file

@ -1809,10 +1809,12 @@ module Infix = struct
type 'a t = 'a list
let (>|=) = (>|=)
let (>>=) = (>>=)
let[@inline] monoid_product l1 l2 = product (fun x y -> x,y) l1 l2
let[@inline] monoid_product l1 l2 = product (fun x y -> x,y) l1 l2
end)
let (and&) = combine_shortest
include CCShimsMkLetList_.Make(struct
let combine_shortest=combine_shortest
end)
end
include Infix

View file

@ -860,22 +860,7 @@ module Infix : sig
@since 2.8 *)
include CCShimsMkLet_.S with type 'a t_let := 'a list
val (and&) : 'a list -> 'b list -> ('a * 'b) list
(** [(and&)] is [combine_shortest]. It allows to perform a synchronized product between two lists,
stopping gently at the shortest. Usable both with [let+] and [let*].
{[
# let f xs ys zs =
let+ x = xs
and& y = ys
and& z = zs in
x + y + z;;
val f : int list -> int list -> int list -> int list = <fun>
# f [1;2] [5;6;7] [10;10];;
- : int list = [16; 18]
]}
@since 3.1
*)
include CCShimsMkLetList_.S
end
(** Let operators on OCaml >= 4.08.0, nothing otherwise

View file

@ -6,8 +6,8 @@
(rule
(targets CCShims_.ml CCShimsList_.ml CCShimsFun_.ml CCShimsFun_.mli
CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsArrayLabels_.ml
CCShimsInt_.ml)
CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsMkLetList_.ml
CCShimsArrayLabels_.ml CCShimsInt_.ml)
(deps ./mkshims.exe)
(action
(run ./mkshims.exe)))

View file

@ -114,7 +114,7 @@ let shims_array_label_post_408 = "
let shims_let_op_pre_408 =
"
(** glue code for let-operators on OCaml >= 4.08 (auto generated) *)
(** glue code for let-operators on OCaml < 4.08 (auto generated) *)
module type S = sig type 'a t_let end
module Make(X:sig type 'a t end) = struct type 'a t_let = 'a X.t end
@ -165,6 +165,39 @@ let shims_let_op_post_408 =
end[@@inline]
"
let shims_let_op_list_pre_408 =
"
(** glue code for let-operators on OCaml < 4.08 (auto generated) *)
module type S = sig end
module Make(X:sig end) = struct end
"
let shims_let_op_list_post_408 =
"module type S = sig
val (and&) : 'a list -> 'b list -> ('a * 'b) list
(** [(and&)] is {!combine_shortest}.
It allows to perform a synchronized product between two lists,
stopping gently at the shortest. Usable both with [let+] and [let*].
{[
# let f xs ys zs =
let+ x = xs
and& y = ys
and& z = zs in
x + y + z;;
val f : int list -> int list -> int list -> int list = <fun>
# f [1;2] [5;6;7] [10;10];;
- : int list = [16; 18]
]}
@since 3.1
*)
end
module Make(X:sig
val combine_shortest : 'a list -> 'b list -> ('a*'b) list
end) = struct
let (and&) = X.combine_shortest
end
"
let shims_int_pre_408 = ""
let shims_int_post_408 = "
include Int
@ -231,6 +264,7 @@ let () =
write_file "CCShimsFun_.ml" (if (major, minor) >= (4,8) then shims_fun_post_408 else shims_fun_pre_408);
write_file "CCShimsFun_.mli" (if (major, minor) >= (4,8) then shims_fun_mli_post_408 else shims_fun_mli_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);
write_file "CCShimsInt_.ml"
((if (major, minor) >= (4,8) then shims_int_post_408 else shims_int_pre_408)
^ if Sys.word_size=64 then shims_int_64bit else shims_int_non_64bit);