mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
fix: use shims again for CCList.(and&)
This commit is contained in:
parent
9068cbc1cc
commit
ca7801a854
4 changed files with 54 additions and 33 deletions
|
|
@ -1809,10 +1809,12 @@ module Infix = struct
|
||||||
type 'a t = 'a list
|
type 'a t = 'a list
|
||||||
let (>|=) = (>|=)
|
let (>|=) = (>|=)
|
||||||
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)
|
end)
|
||||||
|
|
||||||
let (and&) = combine_shortest
|
include CCShimsMkLetList_.Make(struct
|
||||||
|
let combine_shortest=combine_shortest
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
include Infix
|
include Infix
|
||||||
|
|
|
||||||
|
|
@ -860,22 +860,7 @@ module Infix : sig
|
||||||
@since 2.8 *)
|
@since 2.8 *)
|
||||||
include CCShimsMkLet_.S with type 'a t_let := 'a list
|
include CCShimsMkLet_.S with type 'a t_let := 'a list
|
||||||
|
|
||||||
val (and&) : 'a list -> 'b list -> ('a * 'b) list
|
include CCShimsMkLetList_.S
|
||||||
(** [(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
|
end
|
||||||
|
|
||||||
(** Let operators on OCaml >= 4.08.0, nothing otherwise
|
(** Let operators on OCaml >= 4.08.0, nothing otherwise
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
(rule
|
(rule
|
||||||
(targets CCShims_.ml CCShimsList_.ml CCShimsFun_.ml CCShimsFun_.mli
|
(targets CCShims_.ml CCShimsList_.ml CCShimsFun_.ml CCShimsFun_.mli
|
||||||
CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsArrayLabels_.ml
|
CCShimsArray_.ml CCShimsFormat_.ml CCShimsMkLet_.ml CCShimsMkLetList_.ml
|
||||||
CCShimsInt_.ml)
|
CCShimsArrayLabels_.ml CCShimsInt_.ml)
|
||||||
(deps ./mkshims.exe)
|
(deps ./mkshims.exe)
|
||||||
(action
|
(action
|
||||||
(run ./mkshims.exe)))
|
(run ./mkshims.exe)))
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ let shims_array_label_post_408 = "
|
||||||
|
|
||||||
let shims_let_op_pre_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 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
|
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]
|
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_pre_408 = ""
|
||||||
let shims_int_post_408 = "
|
let shims_int_post_408 = "
|
||||||
include Int
|
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_.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 "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 "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"
|
write_file "CCShimsInt_.ml"
|
||||||
((if (major, minor) >= (4,8) then shims_int_post_408 else shims_int_pre_408)
|
((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);
|
^ if Sys.word_size=64 then shims_int_64bit else shims_int_non_64bit);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue