From 8c3d716ab1996b543b21b6f0b01a27d498a0442c Mon Sep 17 00:00:00 2001 From: Fardale Date: Sat, 18 Jul 2020 11:54:46 +0200 Subject: [PATCH] break: rename fonction from *std_seq* to *seq* --- src/core/CCArray.ml | 8 ++++---- src/core/CCArray.mli | 7 ++++--- src/core/CCArrayLabels.mli | 7 ++++--- src/core/CCHashtbl.ml | 32 ++++++++++++++--------------- src/core/CCHashtbl.mli | 40 ++++++++++++++++++++++--------------- src/core/CCHeap.ml | 18 ++++++++--------- src/core/CCHeap.mli | 34 +++++++++++++++---------------- src/core/CCList.ml | 10 +++++----- src/core/CCList.mli | 21 ++++++++++--------- src/core/CCListLabels.mli | 21 ++++++++++--------- src/core/CCMap.ml | 8 ++++---- src/core/CCMap.mli | 14 +++++++------ src/core/CCOpt.ml | 2 +- src/core/CCOpt.mli | 7 ++++--- src/core/CCResult.ml | 2 +- src/core/CCResult.mli | 5 +++-- src/core/CCSet.ml | 12 +++++++++-- src/core/CCSet.mli | 7 +++++++ src/core/CCString.ml | 15 ++++++-------- src/core/CCString.mli | 22 +++++++++++--------- src/core/CCStringLabels.mli | 22 +++++++++++--------- src/core/CCUtf8_string.ml | 10 +++++----- src/core/CCUtf8_string.mli | 10 ++++++---- src/core/CCVector.ml | 14 ++++++------- src/core/CCVector.mli | 27 +++++++++++++++---------- src/data/CCSimple_queue.ml | 18 +++++++---------- src/data/CCSimple_queue.mli | 25 +++++++++++------------ 27 files changed, 230 insertions(+), 188 deletions(-) diff --git a/src/core/CCArray.ml b/src/core/CCArray.ml index d0c7c76f..e60af1d2 100644 --- a/src/core/CCArray.ml +++ b/src/core/CCArray.ml @@ -533,7 +533,7 @@ let to_string ?(sep=", ") item_to_string a = (to_string string_of_int [|1|]) "1" *) -let to_std_seq a = +let to_seq a = let rec aux i () = if i>= length a then Seq.Nil else Seq.Cons (a.(i), aux (i+1)) @@ -541,9 +541,9 @@ let to_std_seq a = aux 0 (*$= - [] (to_std_seq [||] |> CCList.of_std_seq) - [1;2;3] (to_std_seq [|1;2;3|] |> CCList.of_std_seq) - CCList.(1 -- 1000) (to_std_seq (1--1000) |> CCList.of_std_seq) + [] (to_seq [||] |> CCList.of_seq) + [1;2;3] (to_seq [|1;2;3|] |> CCList.of_seq) + CCList.(1 -- 1000) (to_seq (1--1000) |> CCList.of_seq) *) let to_iter a k = iter k a diff --git a/src/core/CCArray.mli b/src/core/CCArray.mli index 10fce6eb..76e7842d 100644 --- a/src/core/CCArray.mli +++ b/src/core/CCArray.mli @@ -189,11 +189,12 @@ val to_iter : 'a t -> 'a iter in modification of the iterator. @since 2.8 *) -val to_std_seq : 'a t -> 'a Seq.t -(** [to_std_seq a] returns a [Seq.t] of the elements of an array [a]. +val to_seq : 'a t -> 'a Seq.t +(** [to_seq a] returns a [Seq.t] of the elements of an array [a]. The input array [a] is shared with the sequence and modification of it will result in modification of the sequence. - @since 2.8 + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_gen : 'a t -> 'a gen diff --git a/src/core/CCArrayLabels.mli b/src/core/CCArrayLabels.mli index abfc34fa..d8043b96 100644 --- a/src/core/CCArrayLabels.mli +++ b/src/core/CCArrayLabels.mli @@ -195,11 +195,12 @@ val to_iter : 'a t -> 'a iter in modification of the iterator. @since 2.8 *) -val to_std_seq : 'a t -> 'a Seq.t -(** [to_std_seq a] returns a [Seq.t] of the elements of an array [a]. +val to_seq : 'a t -> 'a Seq.t +(** [to_seq a] returns a [Seq.t] of the elements of an array [a]. The input array [a] is shared with the sequence and modification of it will result in modification of the sequence. - @since 2.8 + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_gen : 'a t -> 'a gen diff --git a/src/core/CCHashtbl.ml b/src/core/CCHashtbl.ml index 8b3144bf..9ba920dc 100644 --- a/src/core/CCHashtbl.ml +++ b/src/core/CCHashtbl.ml @@ -63,30 +63,30 @@ module Poly = struct let add_iter tbl i = i (fun (k,v) -> Hashtbl.add tbl k v) - let add_std_seq tbl seq = Seq.iter (fun (k,v) -> Hashtbl.add tbl k v) seq + let add_seq tbl seq = Seq.iter (fun (k,v) -> Hashtbl.add tbl k v) seq let of_iter i = let tbl = Hashtbl.create 32 in add_iter tbl i; tbl - let of_std_seq i = + let of_seq i = let tbl = Hashtbl.create 32 in - add_std_seq tbl i; + add_seq tbl i; tbl let add_iter_count tbl i = i (fun k -> incr tbl k) - let add_std_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq + let add_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq let of_iter_count i = let tbl = Hashtbl.create 32 in add_iter_count tbl i; tbl - let of_std_seq_count i = + let of_seq_count i = let tbl = Hashtbl.create 32 in - add_std_seq_count tbl i; + add_seq_count tbl i; tbl let to_list tbl = @@ -210,7 +210,7 @@ module type S = sig (** Add the corresponding pairs to the table, using {!Hashtbl.add}. @since 2.8 *) - val add_std_seq : 'a t -> (key * 'a) Seq.t -> unit + val add_seq : 'a t -> (key * 'a) Seq.t -> unit (** Add the corresponding pairs to the table, using {!Hashtbl.add}. @since 2.8 *) @@ -218,7 +218,7 @@ module type S = sig (** From the given bindings, added in order. @since 2.8 *) - val of_std_seq : (key * 'a) Seq.t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t (** From the given bindings, added in order. @since 2.8 *) @@ -228,7 +228,7 @@ module type S = sig element of [i] occurs. @since 2.8 *) - val add_std_seq_count : int t -> key Seq.t -> unit + val add_seq_count : int t -> key Seq.t -> unit (** [add_seq_count tbl seq] increments the count of each element of [seq] by calling {!incr}. This is useful for counting how many times each element of [seq] occurs. @@ -238,7 +238,7 @@ module type S = sig (** Like {!add_seq_count}, but allocates a new table and returns it. @since 2.8 *) - val of_std_seq_count : key Seq.t -> int t + val of_seq_count : key Seq.t -> int t (** Like {!add_seq_count}, but allocates a new table and returns it. @since 2.8 *) @@ -357,30 +357,30 @@ module Make(X : Hashtbl.HashedType) let add_iter tbl i = i (fun (k,v) -> add tbl k v) - let add_std_seq tbl seq = Seq.iter (fun (k,v) -> add tbl k v) seq + let add_seq tbl seq = Seq.iter (fun (k,v) -> add tbl k v) seq let of_iter i = let tbl = create 32 in add_iter tbl i; tbl - let of_std_seq i = + let of_seq i = let tbl = create 32 in - add_std_seq tbl i; + add_seq tbl i; tbl let add_iter_count tbl i = i (fun k -> incr tbl k) - let add_std_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq + let add_seq_count tbl seq = Seq.iter (fun k -> incr tbl k) seq let of_iter_count seq = let tbl = create 32 in add_iter_count tbl seq; tbl - let of_std_seq_count i = + let of_seq_count i = let tbl = create 32 in - add_std_seq_count tbl i; + add_seq_count tbl i; tbl let to_list tbl = diff --git a/src/core/CCHashtbl.mli b/src/core/CCHashtbl.mli index d9e0072e..3ed4eefd 100644 --- a/src/core/CCHashtbl.mli +++ b/src/core/CCHashtbl.mli @@ -72,17 +72,19 @@ module Poly : sig (** Add the corresponding pairs to the table, using {!Hashtbl.add}. @since 2.8 *) - val add_std_seq : ('a,'b) Hashtbl.t -> ('a * 'b) Seq.t -> unit + val add_seq : ('a,'b) Hashtbl.t -> ('a * 'b) Seq.t -> unit (** Add the corresponding pairs to the table, using {!Hashtbl.add}. - @since 2.8 *) + Renamed from [add_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : ('a * 'b) iter -> ('a,'b) Hashtbl.t (** From the given bindings, added in order. @since 2.8 *) - val of_std_seq : ('a * 'b) Seq.t -> ('a,'b) Hashtbl.t + val of_seq : ('a * 'b) Seq.t -> ('a,'b) Hashtbl.t (** From the given bindings, added in order. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val add_iter_count : ('a, int) Hashtbl.t -> 'a iter -> unit (** [add_iter_count tbl i] increments the count of each element of [i] @@ -90,19 +92,21 @@ module Poly : sig element of [i] occurs. @since 2.8 *) - val add_std_seq_count : ('a, int) Hashtbl.t -> 'a Seq.t -> unit + val add_seq_count : ('a, int) Hashtbl.t -> 'a Seq.t -> unit (** [add_seq_count tbl seq] increments the count of each element of [seq] by calling {!incr}. This is useful for counting how many times each element of [seq] occurs. - @since 2.8 *) + Renamed from [add_std_seq_count] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter_count : 'a iter -> ('a, int) Hashtbl.t (** Like {!add_seq_count}, but allocates a new table and returns it. @since 2.8 *) - val of_std_seq_count : 'a Seq.t -> ('a, int) Hashtbl.t + val of_seq_count : 'a Seq.t -> ('a, int) Hashtbl.t (** Like {!add_seq_count}, but allocates a new table and returns it. - @since 2.8 *) + Renamed from [of_std_seq_count] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_list : ('a,'b) Hashtbl.t -> ('a * 'b) list (** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *) @@ -196,17 +200,19 @@ module type S = sig (** Add the corresponding pairs to the table, using {!Hashtbl.add}. @since 2.8 *) - val add_std_seq : 'a t -> (key * 'a) Seq.t -> unit + val add_seq : 'a t -> (key * 'a) Seq.t -> unit (** Add the corresponding pairs to the table, using {!Hashtbl.add}. - @since 2.8 *) + Renamed from [add_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : (key * 'a) iter -> 'a t (** From the given bindings, added in order. @since 2.8 *) - val of_std_seq : (key * 'a) Seq.t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t (** From the given bindings, added in order. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val add_iter_count : int t -> key iter -> unit (** [add_iter_count tbl i] increments the count of each element of [i] @@ -214,19 +220,21 @@ module type S = sig element of [i] occurs. @since 2.8 *) - val add_std_seq_count : int t -> key Seq.t -> unit + val add_seq_count : int t -> key Seq.t -> unit (** [add_seq_count tbl seq] increments the count of each element of [seq] by calling {!incr}. This is useful for counting how many times each element of [seq] occurs. - @since 2.8 *) + Renamed from [of_std_seq_count] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter_count : key iter -> int t (** Like {!add_seq_count}, but allocates a new table and returns it. @since 2.8 *) - val of_std_seq_count : key Seq.t -> int t + val of_seq_count : key Seq.t -> int t (** Like {!add_seq_count}, but allocates a new table and returns it. - @since 2.8 *) + Renamed from [of_std_seq_count] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_list : 'a t -> (key * 'a) list (** [to_list tbl] returns the list of (key,value) bindings (order unspecified). *) diff --git a/src/core/CCHeap.ml b/src/core/CCHeap.ml index d1894a59..5b7b9e19 100644 --- a/src/core/CCHeap.ml +++ b/src/core/CCHeap.ml @@ -175,7 +175,7 @@ module type S = sig (** Like {!add_list}. @since 2.8 *) - val add_std_seq : t -> elt Seq.t -> t + val add_seq : t -> elt Seq.t -> t (** Like {!add_list}. @since 2.8 *) @@ -183,7 +183,7 @@ module type S = sig (** Build a heap from a given [iter]. Complexity: [O(n log n)]. @since 2.8 *) - val of_std_seq : elt Seq.t -> t + val of_seq : elt Seq.t -> t (** Build a heap from a given [Seq.t]. Complexity: [O(n log n)]. @since 2.8 *) @@ -191,7 +191,7 @@ module type S = sig (** Return a [iter] of the elements of the heap. @since 2.8 *) - val to_std_seq : t -> elt Seq.t + val to_seq : t -> elt Seq.t (** Return a [Seq.t] of the elements of the heap. @since 2.8 *) @@ -199,7 +199,7 @@ module type S = sig (** Iterate on the elements, in increasing order. @since 2.8 *) - val to_std_seq_sorted : t -> elt Seq.t + val to_seq_sorted : t -> elt Seq.t (** Iterate on the elements, in increasing order. @since 2.8 *) @@ -366,17 +366,17 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct i (fun x -> h := insert x !h); !h - let add_std_seq h seq = + let add_seq h seq = let h = ref h in Seq.iter (fun x -> h := insert x !h) seq; !h let of_iter i = add_iter empty i - let of_std_seq seq = add_std_seq empty seq + let of_seq seq = add_seq empty seq let to_iter h k = iter k h - let to_std_seq h = + let to_seq h = (* use an explicit stack [st] *) let rec aux st () = match st with @@ -392,9 +392,9 @@ module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct in fun k -> recurse heap k - let rec to_std_seq_sorted h () = match take h with + let rec to_seq_sorted h () = match take h with | None -> Seq.Nil - | Some (h', x) -> Seq.Cons (x, to_std_seq_sorted h') + | Some (h', x) -> Seq.Cons (x, to_seq_sorted h') let rec add_klist h l = match l() with | `Nil -> h diff --git a/src/core/CCHeap.mli b/src/core/CCHeap.mli index f3ce6daa..fdc67b01 100644 --- a/src/core/CCHeap.mli +++ b/src/core/CCHeap.mli @@ -91,11 +91,7 @@ module type S = sig val size : t -> int (** [size h] is the number of elements in the heap [h]. Linear complexity. *) - (** {2 Conversions} - - The interface of [of_gen], [of_seq], [of_klist] - has changed since 0.16 (the old signatures - are now [add_seq], [add_gen], [add_klist]). *) + (** {2 Conversions} *) val to_list : t -> elt list (** [to_list h] returns the elements of the heap [h], in no particular order. *) @@ -116,35 +112,39 @@ module type S = sig (** [add_iter h iter] is like {!add_list}. @since 2.8 *) - val add_std_seq : t -> elt Seq.t -> t - (** [add_std_seq h seq] is like {!add_list}. - @since 2.8 *) + val add_seq : t -> elt Seq.t -> t + (** [add_seq h seq] is like {!add_list}. + Renamed from [add_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : elt iter -> t (** [of_iter iter] builds a heap from a given [iter]. Complexity: [O(n log n)]. @since 2.8 *) - val of_std_seq : elt Seq.t -> t - (** [of_std_seq seq] builds a heap from a given [Seq.t]. Complexity: [O(n log n)]. - @since 2.8 *) + val of_seq : elt Seq.t -> t + (** [of_seq seq] builds a heap from a given [Seq.t]. Complexity: [O(n log n)]. + Renamed from [of_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_iter : t -> elt iter (** [to_iter h] returns a [iter] of the elements of the heap [h]. @since 2.8 *) - val to_std_seq : t -> elt Seq.t - (** [to_std_seq h] returns a [Seq.t] of the elements of the heap [h]. - @since 2.8 *) + val to_seq : t -> elt Seq.t + (** [to_seq h] returns a [Seq.t] of the elements of the heap [h]. + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_iter_sorted : t -> elt iter (** [to_iter_sorted h] returns a [iter] by iterating on the elements of [h], in increasing order. @since 2.8 *) - val to_std_seq_sorted : t -> elt Seq.t - (** [to_std_seq_sorted h] returns a [Seq.t] by iterating on the elements of [h], + val to_seq_sorted : t -> elt Seq.t + (** [to_seq_sorted h] returns a [Seq.t] by iterating on the elements of [h], in increasing order. - @since 2.8 *) + Renamed from [to_std_seq_sorted] since NEXT_RELEASE. + @since NEXT_RELEASE *) val add_klist : t -> elt klist -> t (** [add_klist h klist] adds the klist [klist] to the heap [h]. diff --git a/src/core/CCList.ml b/src/core/CCList.ml index f3e2a707..5658dc09 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1715,25 +1715,25 @@ let to_string ?(start="") ?(stop="") ?(sep=", ") item_to_string l = let to_iter l k = List.iter k l -let rec to_std_seq l () = match l with +let rec to_seq l () = match l with | [] -> Seq.Nil - | x :: tl -> Seq.Cons (x, to_std_seq tl) + | x :: tl -> Seq.Cons (x, to_seq tl) let of_iter i = let l = ref [] in i (fun x -> l := x :: !l); List.rev !l -let of_std_seq_rev l = +let of_seq_rev l = let rec loop acc s = match s() with | Seq.Nil -> acc | Seq.Cons (x,tl) -> loop (x::acc) tl in loop [] l -let of_std_seq l = +let of_seq l = let rec direct i seq = - if i <= 0 then List.rev (of_std_seq_rev seq) + if i <= 0 then List.rev (of_seq_rev seq) else ( match seq() with | Seq.Nil -> [] diff --git a/src/core/CCList.mli b/src/core/CCList.mli index bf83562c..c85fa092 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -754,23 +754,26 @@ val to_iter : 'a t -> 'a iter (** [to_iter l] returns a [iter] of the elements of the list [l]. @since 2.8 *) -val to_std_seq : 'a t -> 'a Seq.t -(** [to_std_seq l] returns a [Seq.t] of the elements of the list [l]. - @since 2.8 *) +val to_seq : 'a t -> 'a Seq.t +(** [to_seq l] returns a [Seq.t] of the elements of the list [l]. + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : 'a iter -> 'a t (** [of_iter iter] builds a list from a given [iter]. In the result, elements appear in the same order as they did in the source [iter]. @since 2.8 *) -val of_std_seq_rev : 'a Seq.t -> 'a t -(** [of_std_seq_rev seq] builds a list from a given [Seq.t], in reverse order. - @since 2.8 *) +val of_seq_rev : 'a Seq.t -> 'a t +(** [of_seq_rev seq] builds a list from a given [Seq.t], in reverse order. + Renamed from [to_std_seq_rev] since NEXT_RELEASE. + @since NEXT_RELEASE *) -val of_std_seq : 'a Seq.t -> 'a t -(** [of_std_seq seq] builds a list from a given [Seq.t]. +val of_seq : 'a Seq.t -> 'a t +(** [of_seq seq] builds a list from a given [Seq.t]. In the result, elements appear in the same order as they did in the source [Seq.t]. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_gen : 'a t -> 'a gen (** [to_gen l] returns a [gen] of the elements of the list [l]. *) diff --git a/src/core/CCListLabels.mli b/src/core/CCListLabels.mli index cecb8f98..6f9af16b 100644 --- a/src/core/CCListLabels.mli +++ b/src/core/CCListLabels.mli @@ -758,23 +758,26 @@ val to_iter : 'a t -> 'a iter (** [to_iter l] returns a [iter] of the elements of the list [l]. @since 2.8 *) -val to_std_seq : 'a t -> 'a Seq.t -(** [to_std_seq l] returns a [Seq.t] of the elements of the list [l]. - @since 2.8 *) +val to_seq : 'a t -> 'a Seq.t +(** [to_seq l] returns a [Seq.t] of the elements of the list [l]. + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : 'a iter -> 'a t (** [of_iter iter] builds a list from a given [iter]. In the result, elements appear in the same order as they did in the source [iter]. @since 2.8 *) -val of_std_seq_rev : 'a Seq.t -> 'a t -(** [of_std_seq_rev seq] builds a list from a given [Seq.t], in reverse order. - @since 2.8 *) +val of_seq_rev : 'a Seq.t -> 'a t +(** [of_seq_rev seq] builds a list from a given [Seq.t], in reverse order. + Renamed from [of_std_seq_rev] since NEXT_RELEASE. + @since NEXT_RELEASE *) -val of_std_seq : 'a Seq.t -> 'a t -(** [of_std_seq seq] builds a list from a given [Seq.t]. +val of_seq : 'a Seq.t -> 'a t +(** [of_seq seq] builds a list from a given [Seq.t]. In the result, elements appear in the same order as they did in the source [Seq.t]. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_gen : 'a t -> 'a gen (** [to_gen l] returns a [gen] of the elements of the list [l]. *) diff --git a/src/core/CCMap.ml b/src/core/CCMap.ml index 31b0260e..71569760 100644 --- a/src/core/CCMap.ml +++ b/src/core/CCMap.ml @@ -60,11 +60,11 @@ module type S = sig (** Like {!of_list}. @since 2.8 *) - val add_std_seq : 'a t -> (key * 'a) Seq.t -> 'a t + val add_seq : 'a t -> (key * 'a) Seq.t -> 'a t (** Like {!add_list}. @since 2.8 *) - val of_std_seq : (key * 'a) Seq.t -> 'a t + val of_seq : (key * 'a) Seq.t -> 'a t (** Like {!of_list}. @since 2.8 *) @@ -193,12 +193,12 @@ module Make(O : Map.OrderedType) = struct | Some v1, Some v2 -> f k (`Both (v1,v2))) a b - let add_std_seq m s = + let add_seq m s = let m = ref m in Seq.iter (fun (k,v) -> m := add k v !m) s; !m - let of_std_seq s = add_std_seq empty s + let of_seq s = add_seq empty s let add_iter m s = let m = ref m in diff --git a/src/core/CCMap.mli b/src/core/CCMap.mli index f8ab9dc7..39bc0bc7 100644 --- a/src/core/CCMap.mli +++ b/src/core/CCMap.mli @@ -80,15 +80,17 @@ module type S = sig Like {!of_list}. @since 2.8 *) - val add_std_seq : 'a t -> (key * 'a) Seq.t -> 'a t - (** [add_std_seq m seq] adds the given [Seq.t] of bindings to the map [m]. + val add_seq : 'a t -> (key * 'a) Seq.t -> 'a t + (** [add_seq m seq] adds the given [Seq.t] of bindings to the map [m]. Like {!add_list}. - @since 2.8 *) + Renamed from [add_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) - val of_std_seq : (key * 'a) Seq.t -> 'a t - (** [of_std_seq seq] builds a map from the given [Seq.t] of bindings. + val of_seq : (key * 'a) Seq.t -> 'a t + (** [of_seq seq] builds a map from the given [Seq.t] of bindings. Like {!of_list}. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val add_iter : 'a t -> (key * 'a) iter -> 'a t (** [add_iter m iter] adds the given [iter] of bindings to the map [m]. diff --git a/src/core/CCOpt.ml b/src/core/CCOpt.ml index 706049d5..9452aaf4 100644 --- a/src/core/CCOpt.ml +++ b/src/core/CCOpt.ml @@ -228,7 +228,7 @@ let to_iter o k = match o with let to_seq = to_iter -let to_std_seq o () = match o with +let to_seq o () = match o with | None -> Seq.Nil | Some x -> Seq.Cons (x, Seq.empty) diff --git a/src/core/CCOpt.mli b/src/core/CCOpt.mli index 8d2e766b..98ea37a5 100644 --- a/src/core/CCOpt.mli +++ b/src/core/CCOpt.mli @@ -218,11 +218,12 @@ val to_gen : 'a t -> 'a gen (** [to_gen o] is [o] as a [gen]. [Some x] is the singleton [gen] containing [x] and [None] is the empty [gen]. *) -val to_std_seq : 'a t -> 'a Seq.t -(** [to_std_seq o] is [o] as a sequence [Seq.t]. [Some x] is the singleton sequence containing [x] +val to_seq : 'a t -> 'a Seq.t +(** [to_seq o] is [o] as a sequence [Seq.t]. [Some x] is the singleton sequence containing [x] and [None] is the empty sequence. Same as {!Stdlib.Option.to_seq} - @since 2.8 *) + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_iter : 'a t -> 'a iter (** [to_iter o] returns an internal iterator, like in the library [Iter]. diff --git a/src/core/CCResult.ml b/src/core/CCResult.ml index 23ef482a..31c9f3e5 100644 --- a/src/core/CCResult.ml +++ b/src/core/CCResult.ml @@ -341,7 +341,7 @@ let of_opt = function | None -> Error "of_opt" | Some x -> Ok x -let to_std_seq e () = match e with +let to_seq e () = match e with | Ok x -> Seq.Cons (x, Seq.empty) | Error _ -> Seq.Nil diff --git a/src/core/CCResult.mli b/src/core/CCResult.mli index 52cd34fa..8c32f3b7 100644 --- a/src/core/CCResult.mli +++ b/src/core/CCResult.mli @@ -262,8 +262,9 @@ val of_opt : 'a option -> ('a, string) t val to_iter : ('a, _) t -> 'a iter (** @since 2.8 *) -val to_std_seq : ('a, _) t -> 'a Seq.t -(** @since 2.8 *) +val to_seq : ('a, _) t -> 'a Seq.t +(** Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) type ('a, 'b) error = [`Ok of 'a | `Error of 'b] diff --git a/src/core/CCSet.ml b/src/core/CCSet.ml index 29cdeebf..ae4c3039 100644 --- a/src/core/CCSet.ml +++ b/src/core/CCSet.ml @@ -54,9 +54,17 @@ module type S = sig (** Build a set from the given [iter] of elements. @since 2.8 *) + val of_seq : elt Seq.t -> t + (** Build a set from the given [seq] of elements. + @since NEXT_RELEASE *) + val add_iter : t -> elt iter -> t (** @since 2.8 *) + val add_seq : elt Seq.t -> t -> t + (** @since NEXT_RELEASE *) + + val to_iter : t -> elt iter (** [to_iter t] converts the set [t] to a [iter] of the elements. @since 2.8 *) @@ -135,12 +143,12 @@ module Make(O : Map.OrderedType) = struct include S - let add_std_seq set seq = + let add_seq seq set = let set = ref set in Seq.iter (fun x -> set := add x !set) seq; !set - let of_std_seq s = add_std_seq empty s + let of_seq s = add_seq s empty let add_iter set i = let set = ref set in diff --git a/src/core/CCSet.mli b/src/core/CCSet.mli index e4a568e5..6779e710 100644 --- a/src/core/CCSet.mli +++ b/src/core/CCSet.mli @@ -53,9 +53,16 @@ module type S = sig (** Build a set from the given [iter] of elements. @since 2.8 *) + val of_seq : elt Seq.t -> t + (** Build a set from the given [seq] of elements. + @since NEXT_RELEASE *) + val add_iter : t -> elt iter -> t (** @since 2.8 *) + val add_seq : elt Seq.t -> t -> t + (** @since NEXT_RELEASE *) + val to_iter : t -> elt iter (** [to_iter t] converts the set [t] to a [iter] of the elements. @since 2.8 *) diff --git a/src/core/CCString.ml b/src/core/CCString.ml index 49f79df2..946c5451 100644 --- a/src/core/CCString.ml +++ b/src/core/CCString.ml @@ -416,9 +416,9 @@ module Split = struct Seq.Cons (k s i len , make state') in make (SplitAt 0) - let std_seq ?(drop=default_drop) ~by s = _mkseq ~drop ~by s _tuple3 + let seq ?(drop=default_drop) ~by s = _mkseq ~drop ~by s _tuple3 - let std_seq_cpy ?(drop=default_drop) ~by s = _mkseq ~drop ~by s String.sub + let seq_cpy ?(drop=default_drop) ~by s = _mkseq ~drop ~by s String.sub let _mkklist ~drop ~by s k = let by = Find.compile by in @@ -446,9 +446,6 @@ module Split = struct let iter ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s _tuple3 let iter_cpy ?(drop=default_drop) ~by s = _mk_iter ~drop ~by s String.sub - let seq = iter - let seq_cpy = iter_cpy - let left_exn ~by s = let i = find ~sub:by s in if i = ~-1 then raise Not_found @@ -815,18 +812,18 @@ let of_gen g = let to_iter s k = String.iter k s -let rec _to_std_seq s i len () = +let rec _to_seq s i len () = if len=0 then Seq.Nil - else Seq.Cons (s.[i], _to_std_seq s (i+1)(len-1)) + else Seq.Cons (s.[i], _to_seq s (i+1)(len-1)) -let to_std_seq s = _to_std_seq s 0 (String.length s) +let to_seq s = _to_seq s 0 (String.length s) let of_iter i = let b = Buffer.create 32 in i (Buffer.add_char b); Buffer.contents b -let of_std_seq seq = +let of_seq seq = let b = Buffer.create 32 in Seq.iter (Buffer.add_char b) seq; Buffer.contents b diff --git a/src/core/CCString.mli b/src/core/CCString.mli index 3b8eaf09..1aa42861 100644 --- a/src/core/CCString.mli +++ b/src/core/CCString.mli @@ -44,9 +44,10 @@ val to_iter : t -> char iter (** Return the [iter] of characters contained in the string. @since 2.8 *) -val to_std_seq : t -> char Seq.t -(** [to_std_seq s] returns a [Seq.t] of the bytes in [s]. - @since 2.8 +val to_seq : t -> char Seq.t +(** [to_seq s] returns a [Seq.t] of the bytes in [s]. + Renamed from [to std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_list : t -> char list @@ -90,9 +91,10 @@ val of_iter : char iter -> string (** Convert a [iter] of characters to a string. @since 2.8 *) -val of_std_seq : char Seq.t -> string +val of_seq : char Seq.t -> string (** Convert a [sequence] of characters to a string. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_list : char list -> string (** Convert a list of characters to a string. *) @@ -346,8 +348,9 @@ module Split : sig val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter (** @since 2.8 *) - val std_seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t - (** @since 2.8 *) + val seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t + (** Renamed from [std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) (** {4 Copying functions} @@ -361,8 +364,9 @@ module Split : sig val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter (** @since 2.8 *) - val std_seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t - (** @since 2.8 *) + val seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t + (** Renamed from [std_seq_cpy] since NEXT_RELEASE. + @since NEXT_RELEASE *) val left : by:string -> string -> (string * string) option (** Split on the first occurrence of [by] from the leftmost part of diff --git a/src/core/CCStringLabels.mli b/src/core/CCStringLabels.mli index 0206fc3a..535e9f3c 100644 --- a/src/core/CCStringLabels.mli +++ b/src/core/CCStringLabels.mli @@ -42,9 +42,10 @@ val to_iter : t -> char iter (** Return the [iter] of characters contained in the string. @since 2.8 *) -val to_std_seq : t -> char Seq.t -(** [to_std_seq s] returns a [Seq.t] of the bytes in [s]. - @since 2.8 +val to_seq : t -> char Seq.t +(** [to_seq s] returns a [Seq.t] of the bytes in [s]. + Renamed from [to std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_list : t -> char list @@ -93,9 +94,10 @@ val of_iter : char iter -> string (** Convert a [iter] of characters to a string. @since 2.8 *) -val of_std_seq : char Seq.t -> string +val of_seq : char Seq.t -> string (** Convert a [sequence] of characters to a string. - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_list : char list -> string (** Convert a list of characters to a string. *) @@ -365,8 +367,9 @@ module Split : sig val iter : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) iter (** @since 2.8 *) - val std_seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t - (** @since 2.8 *) + val seq : ?drop:drop_if_empty -> by:string -> string -> (string*int*int) Seq.t + (** Renamed from [std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) (** {4 Copying functions} @@ -380,8 +383,9 @@ module Split : sig val iter_cpy : ?drop:drop_if_empty -> by:string -> string -> string iter (** @since 2.8 *) - val std_seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t - (** @since 2.8 *) + val seq_cpy : ?drop:drop_if_empty -> by:string -> string -> string Seq.t + (** Renamed from [std_seq_cpy] since NEXT_RELEASE. + @since NEXT_RELEASE *) val left : by:(string [@keep_label]) -> string -> (string * string) option (** Split on the first occurrence of [by] from the leftmost part of diff --git a/src/core/CCUtf8_string.ml b/src/core/CCUtf8_string.ml index 003784c4..4811098e 100644 --- a/src/core/CCUtf8_string.ml +++ b/src/core/CCUtf8_string.ml @@ -124,7 +124,7 @@ let to_iter ?(idx=0) s : uchar iter = done with Stop -> () -let to_std_seq ?(idx=0) s : uchar Seq.t = +let to_seq ?(idx=0) s : uchar Seq.t = let rec loop st = let r = ref None in fun () -> @@ -141,15 +141,15 @@ let to_std_seq ?(idx=0) s : uchar Seq.t = loop st (*$= & ~cmp:(=) ~printer:Q.Print.(list (fun c -> string_of_int@@ Uchar.to_int c)) - (to_list (of_string_exn "aébõ😀")) (to_std_seq (of_string_exn "aébõ😀") |> CCList.of_std_seq) + (to_list (of_string_exn "aébõ😀")) (to_seq (of_string_exn "aébõ😀") |> CCList.of_seq) *) (* make sure it's persisted correctly *) (*$R let s = (of_string_exn "aébõ😀") in - let seq = to_std_seq s in + let seq = to_seq s in let l = to_list s in - let testeq seq = assert_equal ~cmp:(=) l (CCList.of_std_seq seq) in + let testeq seq = assert_equal ~cmp:(=) l (CCList.of_seq seq) in testeq seq; testeq seq; testeq seq; @@ -213,7 +213,7 @@ let of_gen g : t = in aux () -let of_std_seq seq : t = +let of_seq seq : t = let buf = Buffer.create 32 in Seq.iter (code_to_string buf) seq; Buffer.contents buf diff --git a/src/core/CCUtf8_string.mli b/src/core/CCUtf8_string.mli index 147d1e99..00d866ca 100644 --- a/src/core/CCUtf8_string.mli +++ b/src/core/CCUtf8_string.mli @@ -50,10 +50,11 @@ val to_iter : ?idx:int -> t -> uchar iter @param idx offset where to start the decoding. @since 2.8 *) -val to_std_seq : ?idx:int -> t -> uchar Seq.t +val to_seq : ?idx:int -> t -> uchar Seq.t (** Iter of unicode codepoints. + Renamed from [to_std_seq] since NEXT_RELEASE. @param idx offset where to start the decoding. - @since 2.8 + @since NEXT_RELEASE *) val to_list : ?idx:int -> t -> uchar list @@ -80,9 +81,10 @@ val append : t -> t -> t val concat : t -> t list -> t -val of_std_seq : uchar Seq.t -> t +val of_seq : uchar Seq.t -> t (** Build a string from unicode codepoints - @since 2.8 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val of_iter : uchar iter -> t (** Build a string from unicode codepoints diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 02c837c7..9774a395 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -286,7 +286,7 @@ let remove_unordered v i = let append_iter a i = i (fun x -> push a x) -let append_std_seq a seq = Seq.iter (fun x -> push a x) seq +let append_seq a seq = Seq.iter (fun x -> push a x) seq let append_array a b = let len_b = Array.length b in @@ -839,12 +839,12 @@ let flat_map_iter f v = v; v' -let flat_map_std_seq f v = +let flat_map_seq f v = let v' = create () in iter (fun x -> let seq = f x in - append_std_seq v' seq) + append_seq v' seq) v; v' @@ -941,8 +941,8 @@ let of_iter ?(init=create ()) seq = append_iter init seq; init -let of_std_seq ?(init=create ()) seq = - append_std_seq init seq; +let of_seq ?(init=create ()) seq = + append_seq init seq; init (*$T @@ -957,14 +957,14 @@ let to_iter_rev v k = k (Array.unsafe_get v.vec i) done -let to_std_seq v = +let to_seq v = let rec aux i () = if i>= size v then Seq.Nil else Seq.Cons (v.vec.(i), aux (i+1)) in aux 0 -let to_std_seq_rev v = +let to_seq_rev v = let rec aux i () = if i<0 || i > size v then Seq.Nil else Seq.Cons (v.vec.(i), aux (i-1)) diff --git a/src/core/CCVector.mli b/src/core/CCVector.mli index 22a61a0a..1e5fa42c 100644 --- a/src/core/CCVector.mli +++ b/src/core/CCVector.mli @@ -86,9 +86,10 @@ val append_iter : ('a, rw) t -> 'a iter -> unit (** Append content of iterator. @since 2.8 *) -val append_std_seq : ('a, rw) t -> 'a Seq.t -> unit +val append_seq : ('a, rw) t -> 'a Seq.t -> unit (** Append content of iterator. - @since 2.8 *) + Renamed from [append_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val append_list : ('a, rw) t -> 'a list -> unit (** Append content of list. @@ -209,9 +210,10 @@ val filter_map_in_place : ('a -> 'a option) -> ('a,_) t -> unit val flat_map : ('a -> ('b,_) t) -> ('a,_) t -> ('b, 'mut) t (** Map each element to a sub-vector. *) -val flat_map_std_seq : ('a -> 'b Seq.t) -> ('a,_) t -> ('b, 'mut) t +val flat_map_seq : ('a -> 'b Seq.t) -> ('a,_) t -> ('b, 'mut) t (** Like {!flat_map}, but using [Seq] for intermediate collections. - @since 2.8 *) + Renamed from [flat_map_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val flat_map_list : ('a -> 'b list) -> ('a,_) t -> ('b, 'mut) t (** Like {!flat_map}, but using {!list} for @@ -298,9 +300,10 @@ val of_iter : ?init:('a,rw) t -> 'a iter -> ('a, rw) t (** Convert an Iterator to a vector. @since 2.8.1 *) -val of_std_seq : ?init:('a,rw) t -> 'a Seq.t -> ('a, rw) t +val of_seq : ?init:('a,rw) t -> 'a Seq.t -> ('a, rw) t (** Convert an Iterator to a vector. - @since 2.8.1 *) + Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_iter : ('a,_) t -> 'a iter (** Return a [iter] with the elements contained in the vector. @@ -313,15 +316,17 @@ val to_iter_rev : ('a,_) t -> 'a iter @since 2.8 *) -val to_std_seq : ('a,_) t -> 'a Seq.t +val to_seq : ('a,_) t -> 'a Seq.t (** Return an iterator with the elements contained in the vector. - @since 2.8 + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) -val to_std_seq_rev : ('a,_) t -> 'a Seq.t +val to_seq_rev : ('a,_) t -> 'a Seq.t (** [to_seq v] returns the sequence of elements of [v] in reverse order, that is, the last elements of [v] are iterated on first. - @since 2.8 + Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val slice : ('a,rw) t -> ('a array * int * int) @@ -329,7 +334,7 @@ val slice : ('a,rw) t -> ('a array * int * int) be careful!. *) val slice_iter : ('a,_) t -> int -> int -> 'a iter -(** [slice_seq v start len] is the sequence of elements from [v.(start)] +(** [slice_iter v start len] is the sequence of elements from [v.(start)] to [v.(start+len-1)]. @since NEXT_RELEASE *) diff --git a/src/data/CCSimple_queue.ml b/src/data/CCSimple_queue.ml index 25ecf393..9aa4e5dd 100644 --- a/src/data/CCSimple_queue.ml +++ b/src/data/CCSimple_queue.ml @@ -117,23 +117,19 @@ let add_iter q seq = let of_iter s = add_iter empty s -let of_seq = of_iter -let to_seq = to_iter -let add_seq = add_iter - (*$Q Q.(list small_int) (fun l -> \ equal CCInt.equal \ - (of_seq (Iter.of_list l)) \ + (of_iter (Iter.of_list l)) \ (of_list l)) Q.(list small_int) (fun l -> \ - l = (of_list l |> to_seq |> Iter.to_list)) + l = (of_list l |> to_iter |> Iter.to_list)) *) -let add_std_seq q l = add_iter q (fun k -> Seq.iter k l) -let of_std_seq l = add_std_seq empty l +let add_seq q l = add_iter q (fun k -> Seq.iter k l) +let of_seq l = add_seq empty l -let to_std_seq q = +let to_seq q = let rec aux1 l () = match l with | [] -> aux2 (List.rev q.tl) () | x :: tl -> Seq.Cons (x, aux1 tl) @@ -147,7 +143,7 @@ let rec klist_iter_ k f = match k() with | `Nil -> () | `Cons (x,tl) -> f x; klist_iter_ tl f -let add_klist q l = add_seq q (klist_iter_ l) +let add_klist q l = add_iter q (klist_iter_ l) let of_klist l = add_klist empty l let to_klist q = @@ -164,7 +160,7 @@ let rec gen_iter g f = match g() with | None -> () | Some x -> f x; gen_iter g f -let add_gen q g = add_seq q (gen_iter g) +let add_gen q g = add_iter q (gen_iter g) let of_gen g = add_gen empty g let to_gen q = diff --git a/src/data/CCSimple_queue.mli b/src/data/CCSimple_queue.mli index 5825137b..55e9d891 100644 --- a/src/data/CCSimple_queue.mli +++ b/src/data/CCSimple_queue.mli @@ -88,27 +88,26 @@ val to_iter : 'a t -> 'a iter val add_iter : 'a t -> 'a iter -> 'a t val of_iter : 'a iter -> 'a t -val to_seq : 'a t -> 'a sequence -[@@ocaml.deprecated "use to_iter"] +val to_seq : 'a t -> 'a Seq.t +(** Renamed from [to_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) -val add_seq : 'a t -> 'a sequence -> 'a t -[@@ocaml.deprecated "use add_iter"] +val add_seq : 'a t -> 'a Seq.t -> 'a t +(** Renamed from [add_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) -val of_seq : 'a sequence -> 'a t -[@@ocaml.deprecated "use of_iter"] - -val to_std_seq : 'a t -> 'a Seq.t -val add_std_seq : 'a t -> 'a Seq.t -> 'a t -val of_std_seq : 'a Seq.t -> 'a t +val of_seq : 'a Seq.t -> 'a t +(** Renamed from [of_std_seq] since NEXT_RELEASE. + @since NEXT_RELEASE *) val to_klist : 'a t -> 'a klist -[@@ocaml.deprecated "use to_std_seq"] +[@@ocaml.deprecated "use to_seq"] val add_klist : 'a t -> 'a klist -> 'a t -[@@ocaml.deprecated "use add_std_seq"] +[@@ocaml.deprecated "use add_seq"] val of_klist : 'a klist -> 'a t -[@@ocaml.deprecated "use of_std_seq"] +[@@ocaml.deprecated "use of_seq"] val of_gen : 'a gen -> 'a t val add_gen : 'a t -> 'a gen -> 'a t