From b48fd736ba76cc2aa43ea5614ac6db963d05e1f4 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 7 Mar 2018 13:59:52 -0800 Subject: [PATCH 1/5] [Belt] Change ofArray to fromArray, and ofFoo to fromFoo in general Discussed offline. Easier API to guess. Only changed the externally visible APIs. Didn't check in the JS files; too much noise for now. --- jscomp/others/belt_HashMap.ml | 4 ++- jscomp/others/belt_HashMap.mli | 4 ++- jscomp/others/belt_HashMapInt.ml | 4 ++- jscomp/others/belt_HashMapInt.mli | 5 ++- jscomp/others/belt_HashMapString.ml | 4 ++- jscomp/others/belt_HashMapString.mli | 5 ++- jscomp/others/belt_HashSet.ml | 3 +- jscomp/others/belt_HashSet.mli | 3 ++ jscomp/others/belt_HashSetInt.ml | 4 ++- jscomp/others/belt_HashSetInt.mli | 3 ++ jscomp/others/belt_HashSetString.ml | 4 ++- jscomp/others/belt_HashSetString.mli | 3 ++ jscomp/others/belt_List.ml | 4 ++- jscomp/others/belt_List.mli | 5 ++- jscomp/others/belt_Map.ml | 5 +-- jscomp/others/belt_Map.mli | 31 ++++++++-------- jscomp/others/belt_MapDict.ml | 1 + jscomp/others/belt_MapDict.mli | 5 +-- jscomp/others/belt_MapInt.ml | 1 + jscomp/others/belt_MapInt.mli | 2 ++ jscomp/others/belt_MapString.ml | 1 + jscomp/others/belt_MapString.mli | 2 ++ jscomp/others/belt_MutableMap.ml | 4 ++- jscomp/others/belt_MutableMap.mli | 5 ++- jscomp/others/belt_MutableMapInt.ml | 4 ++- jscomp/others/belt_MutableMapInt.mli | 4 +++ jscomp/others/belt_MutableMapString.ml | 4 ++- jscomp/others/belt_MutableMapString.mli | 4 +++ jscomp/others/belt_MutableQueue.ml | 6 ++-- jscomp/others/belt_MutableQueue.mli | 5 ++- jscomp/others/belt_MutableSet.ml | 9 +++-- jscomp/others/belt_MutableSet.mli | 10 ++++-- jscomp/others/belt_MutableSetInt.ml | 9 +++-- jscomp/others/belt_MutableSetInt.mli | 6 ++++ jscomp/others/belt_MutableSetString.ml | 9 +++-- jscomp/others/belt_MutableSetString.mli | 6 ++++ jscomp/others/belt_Set.ml | 10 +++--- jscomp/others/belt_Set.mli | 48 ++++++++++++++----------- jscomp/others/belt_SetDict.ml | 1 + jscomp/others/belt_SetDict.mli | 8 ++--- jscomp/others/hashmap.cppo.ml | 4 ++- jscomp/others/hashmap.cppo.mli | 5 ++- jscomp/others/hashset.cppo.ml | 4 ++- jscomp/others/hashset.cppo.mli | 3 ++ jscomp/others/map.cppo.ml | 1 + jscomp/others/map.cppo.mli | 2 ++ jscomp/others/mapm.cppo.ml | 4 ++- jscomp/others/mapm.cppo.mli | 4 +++ jscomp/others/setm.cppo.ml | 9 +++-- jscomp/others/setm.cppo.mli | 6 ++++ 50 files changed, 217 insertions(+), 80 deletions(-) diff --git a/jscomp/others/belt_HashMap.ml b/jscomp/others/belt_HashMap.ml index 4c12218166..013c9778a0 100644 --- a/jscomp/others/belt_HashMap.ml +++ b/jscomp/others/belt_HashMap.ml @@ -201,7 +201,7 @@ let make (type key) (type identity) ~hintSize ~(id : (key,identity) id) = C.make ~hash:M.hash ~eq:M.eq ~hintSize -let ofArray (type a) (type identity) arr ~id:(id:(a,identity) id) = +let fromArray (type a) (type identity) arr ~id:(id:(a,identity) id) = let module M = (val id) in let hash, eq = M.hash, M.eq in let len = A.length arr in @@ -212,6 +212,8 @@ let ofArray (type a) (type identity) arr ~id:(id:(a,identity) id) = set0 ~eq ~hash v key value done ; v + +let ofArray = fromArray let mergeMany h arr = let hash, eq = Belt_Id.getHashInternal ( C.hash h) , Belt_Id.getEqInternal (C.eq h) in diff --git a/jscomp/others/belt_HashMap.mli b/jscomp/others/belt_HashMap.mli index df4d66b358..a8e6425bcf 100644 --- a/jscomp/others/belt_HashMap.mli +++ b/jscomp/others/belt_HashMap.mli @@ -149,9 +149,11 @@ val size: _ t -> int val toArray: ('key, 'value, 'id ) t -> ('key * 'value) array val keysToArray: ('key, _, _) t -> 'key array val valuesToArray: (_,'value,_) t -> 'value array -val ofArray: ('key * 'value) array -> id:('key,'id) id -> ('key, 'value, 'id ) t +val fromArray: ('key * 'value) array -> id:('key,'id) id -> ('key, 'value, 'id ) t val mergeMany: ('key, 'value, 'id ) t -> ('key * 'value) array -> unit val getBucketHistogram: _ t -> int array val logStats: _ t -> unit +val ofArray: ('key * 'value) array -> id:('key,'id) id -> ('key, 'value, 'id ) t +[@@ocaml.deprecated "Use fromArray instead"] diff --git a/jscomp/others/belt_HashMapInt.ml b/jscomp/others/belt_HashMapInt.ml index 40bfe636d5..14bcf9a21b 100644 --- a/jscomp/others/belt_HashMapInt.ml +++ b/jscomp/others/belt_HashMapInt.ml @@ -187,7 +187,7 @@ let valuesToArray = N.valuesToArray let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = make len in for i = 0 to len - 1 do @@ -196,6 +196,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/belt_HashMapInt.mli b/jscomp/others/belt_HashMapInt.mli index 30f0b47b3c..1c734ffca5 100644 --- a/jscomp/others/belt_HashMapInt.mli +++ b/jscomp/others/belt_HashMapInt.mli @@ -42,7 +42,10 @@ val size: _ t -> int val toArray: 'a t -> (key * 'a) array val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array -val ofArray: (key * 'a) array -> 'a t +val fromArray: (key * 'a) array -> 'a t val mergeMany: 'a t -> (key * 'a) array -> unit val getBucketHistogram: _ t -> int array val logStats: _ t -> unit + +val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] diff --git a/jscomp/others/belt_HashMapString.ml b/jscomp/others/belt_HashMapString.ml index 1a30d38794..5a6dabd9e3 100644 --- a/jscomp/others/belt_HashMapString.ml +++ b/jscomp/others/belt_HashMapString.ml @@ -187,7 +187,7 @@ let valuesToArray = N.valuesToArray let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = make len in for i = 0 to len - 1 do @@ -196,6 +196,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/belt_HashMapString.mli b/jscomp/others/belt_HashMapString.mli index be3fe06942..10b281bd33 100644 --- a/jscomp/others/belt_HashMapString.mli +++ b/jscomp/others/belt_HashMapString.mli @@ -42,7 +42,10 @@ val size: _ t -> int val toArray: 'a t -> (key * 'a) array val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array -val ofArray: (key * 'a) array -> 'a t +val fromArray: (key * 'a) array -> 'a t val mergeMany: 'a t -> (key * 'a) array -> unit val getBucketHistogram: _ t -> int array val logStats: _ t -> unit + +val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] diff --git a/jscomp/others/belt_HashSet.ml b/jscomp/others/belt_HashSet.ml index d1ca8f46ff..1316850ee4 100644 --- a/jscomp/others/belt_HashSet.ml +++ b/jscomp/others/belt_HashSet.ml @@ -176,7 +176,7 @@ let copy = N.copy let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray (type a) (type identity) arr ~(id:(a,identity) id) = +let fromArray (type a) (type identity) arr ~(id:(a,identity) id) = let module M = (val id) in let eq, hash = M.eq , M.hash in let len = A.length arr in @@ -186,6 +186,7 @@ let ofArray (type a) (type identity) arr ~(id:(a,identity) id) = done ; v +let ofArray = fromArray let mergeMany h arr = let eq, hash = C.eq h, C.hash h in diff --git a/jscomp/others/belt_HashSet.mli b/jscomp/others/belt_HashSet.mli index 40adaff244..b46985a487 100644 --- a/jscomp/others/belt_HashSet.mli +++ b/jscomp/others/belt_HashSet.mli @@ -117,6 +117,9 @@ val logStats: _ t -> unit val toArray: ('a,'id) t -> 'a array val ofArray: 'a array -> id:('a,'id) id -> ('a,'id) t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: 'a array -> id:('a,'id) id -> ('a,'id) t val mergeMany: ('a,'id) t -> 'a array -> unit diff --git a/jscomp/others/belt_HashSetInt.ml b/jscomp/others/belt_HashSetInt.ml index 07ca3ef888..d4d20ea14e 100644 --- a/jscomp/others/belt_HashSetInt.ml +++ b/jscomp/others/belt_HashSetInt.ml @@ -138,7 +138,7 @@ let copy = N.copy let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = C.make ~hintSize:len ~hash:() ~eq:() in for i = 0 to len - 1 do @@ -146,6 +146,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/belt_HashSetInt.mli b/jscomp/others/belt_HashSetInt.mli index 9834940665..c2146ddcdf 100644 --- a/jscomp/others/belt_HashSetInt.mli +++ b/jscomp/others/belt_HashSetInt.mli @@ -67,6 +67,9 @@ val logStats: t -> unit val toArray: t -> key array val ofArray: key array -> t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: key array -> t val mergeMany: t -> key array -> unit diff --git a/jscomp/others/belt_HashSetString.ml b/jscomp/others/belt_HashSetString.ml index dd5abe47f0..0e6a6f5afd 100644 --- a/jscomp/others/belt_HashSetString.ml +++ b/jscomp/others/belt_HashSetString.ml @@ -139,7 +139,7 @@ let copy = N.copy let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = C.make ~hintSize:len ~hash:() ~eq:() in for i = 0 to len - 1 do @@ -147,6 +147,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/belt_HashSetString.mli b/jscomp/others/belt_HashSetString.mli index d27cf28493..30f1e882fb 100644 --- a/jscomp/others/belt_HashSetString.mli +++ b/jscomp/others/belt_HashSetString.mli @@ -67,6 +67,9 @@ val logStats: t -> unit val toArray: t -> key array val ofArray: key array -> t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: key array -> t val mergeMany: t -> key array -> unit diff --git a/jscomp/others/belt_List.ml b/jscomp/others/belt_List.ml index 8bb45a28bb..eaba577e2c 100644 --- a/jscomp/others/belt_List.ml +++ b/jscomp/others/belt_List.ml @@ -398,9 +398,11 @@ let rec ofArrayAux a i res = if i < 0 then res else ofArrayAux a (i - 1) (A.getUnsafe a i :: res) -let ofArray a = +let fromArray a = ofArrayAux a (A.length a - 1) [] +let ofArray = fromArray + let toArray ( x : _ t) = let len = length x in let arr = A.makeUninitializedUnsafe len in diff --git a/jscomp/others/belt_List.mli b/jscomp/others/belt_List.mli index 8c80617e68..096c409bac 100644 --- a/jscomp/others/belt_List.mli +++ b/jscomp/others/belt_List.mli @@ -249,8 +249,11 @@ val mapWithIndex: 'a t -> (int -> 'a -> 'b) -> 'b t *) val ofArray: 'a array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: 'a array -> 'a t (** @example {[ - ofArray [|1;2;3|] = [1;2;3] + fromArray [|1;2;3|] = [1;2;3] ]} *) diff --git a/jscomp/others/belt_Map.ml b/jscomp/others/belt_Map.ml index 0bf5d64e9f..e352c58058 100644 --- a/jscomp/others/belt_Map.ml +++ b/jscomp/others/belt_Map.ml @@ -40,11 +40,12 @@ end type ('k, 'v, 'id ) t = ('k, 'v, 'id) S.t -let ofArray (type k) (type idx) data ~(id : (k,idx) id) = +let fromArray (type k) (type idx) data ~(id : (k,idx) id) = let module M = (val id) in let cmp = M.cmp in - S.t ~cmp ~data:(Dict.ofArray ~cmp data) + S.t ~cmp ~data:(Dict.fromArray ~cmp data) +let ofArray = fromArray let remove m x = let cmp, odata = S.cmp m, S.data m in diff --git a/jscomp/others/belt_Map.mli b/jscomp/others/belt_Map.mli index b3972546a9..2f1eaac9ba 100644 --- a/jscomp/others/belt_Map.mli +++ b/jscomp/others/belt_Map.mli @@ -135,7 +135,7 @@ val isEmpty: _ t -> bool (** [isEmpty s0] @example {[ module IntCmp = (val Belt.Id.comparable (fun (x:int) y -> Pervasives.compare x y));; - isEmpty (ofArray [|1,"1"|] ~id:(module IntCmp)) = false;; + isEmpty (fromArray [|1,"1"|] ~id:(module IntCmp)) = false;; ]} *) @@ -144,7 +144,7 @@ val has: ('k, 'v, 'id) t -> 'k -> bool @example {[ module IntCmp = (val Belt.Id.comparable (fun (x:int) y -> Pervasives.compare x y));; - has (ofArray [|1,"1"|] ~id:(module IntCmp)) 1 = true;; + has (fromArray [|1,"1"|] ~id:(module IntCmp)) 1 = true;; ]} *) @@ -191,7 +191,7 @@ val forEach: ('k, 'v, 'id) t -> ('k -> 'v -> unit) -> unit module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; + let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; let acc = ref [] ;; forEach s0 (fun k v -> acc := (k,v) :: !acc);; @@ -209,7 +209,7 @@ val reduce: ('k, 'v, 'id) t -> 'acc -> ('acc -> 'k -> 'v -> 'acc) -> 'acc module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; + let s0 = fromArray ~id:(module IntCmp) [|4,"4";1,"1";2,"2,"3""|];; reduce s0 [] (fun acc k v -> (k,v) acc ) = [4,"4";3,"3";2,"2";1,"1"];; ]} *) @@ -230,7 +230,7 @@ val size: ('k, 'v, 'id) t -> int @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - size (ofArray [2,"2"; 2,"1"; 3,"3"] ~id:(module IntCmp)) = 2 ;; + size (fromArray [2,"2"; 2,"1"; 3,"3"] ~id:(module IntCmp)) = 2 ;; ]} *) val toArray: ('k, 'v, 'id) t -> ('k * 'v) array @@ -239,7 +239,7 @@ val toArray: ('k, 'v, 'id) t -> ('k * 'v) array @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - toArray (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"] + toArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"] ]} *) @@ -250,11 +250,14 @@ val toList: ('k, 'v, 'id) t -> ('k * 'v) list *) val ofArray: ('k * 'v) array -> id:('k,'id) id -> ('k,'v,'id) t -(** [ofArray kvs ~id] +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: ('k * 'v) array -> id:('k,'id) id -> ('k,'v,'id) t +(** [fromArray kvs ~id] @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - toArray (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"] + toArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [1,"1";2,"2";3,"3"] ]} *) val keysToArray: ('k, 'v, 'id) t -> 'k array @@ -263,7 +266,7 @@ val keysToArray: ('k, 'v, 'id) t -> 'k array @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - keysToArray (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = + keysToArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [|1;2;3|];; ]} *) @@ -273,7 +276,7 @@ val valuesToArray: ('k, 'v, 'id) t -> 'v array @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - valuesToArray (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = + valuesToArray (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) = [|"1";"2";"3"|];; ]} @@ -318,9 +321,9 @@ val get: ('k, 'v, 'id) t -> 'k -> 'v option @example {[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - get (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 = + get (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 = Some "2";; - get (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 = + get (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp)) 2 = None;; ]} *) @@ -356,7 +359,7 @@ val remove: ('k, 'v, 'id) t -> 'k -> ('k, 'v, 'id) t module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));; + let s0 = (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));; let s1 = remove s0 1;; let s2 = remove s1 1;; @@ -384,7 +387,7 @@ val set: module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = (ofArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));; + let s0 = (fromArray [2,"2"; 1,"1"; 3,"3"] ~id:(module IntCmp));; let s1 = set s0 2 "3";; diff --git a/jscomp/others/belt_MapDict.ml b/jscomp/others/belt_MapDict.ml index 2aab9871f3..bac2c07e14 100644 --- a/jscomp/others/belt_MapDict.ml +++ b/jscomp/others/belt_MapDict.ml @@ -30,6 +30,7 @@ type ('key, 'a, 'id) t = ('key, 'a) N.t type ('key, 'id) cmp = ('key, 'id) Belt_Id.cmp let empty = N.empty +let fromArray = N.ofArray let ofArray = N.ofArray let isEmpty = N.isEmpty let cmp = N.cmp diff --git a/jscomp/others/belt_MapDict.mli b/jscomp/others/belt_MapDict.mli index ad2db15ee1..de9d7dfc67 100644 --- a/jscomp/others/belt_MapDict.mli +++ b/jscomp/others/belt_MapDict.mli @@ -92,8 +92,9 @@ val size: ('k, 'a, 'id) t -> int val toList: ('k, 'a, 'id) t -> ('k * 'a) list (** In increasing order*) val toArray: ('k, 'a, 'id) t -> ('k * 'a) array -val ofArray: - ('k * 'a) array -> cmp:('k,'id) cmp -> ('k,'a,'id) t +val ofArray: ('k * 'a) array -> cmp:('k,'id) cmp -> ('k,'a,'id) t +[@@ocaml.deprecated "Use fromArray instead"] +val fromArray: ('k * 'a) array -> cmp:('k,'id) cmp -> ('k,'a,'id) t val keysToArray: ('k, 'a, 'id) t -> 'k array val valuesToArray: ('k, 'a, 'id) t -> 'a array val minKey: ('k, _, _) t -> 'k option diff --git a/jscomp/others/belt_MapInt.ml b/jscomp/others/belt_MapInt.ml index 585cd2b479..8c5ee023e5 100644 --- a/jscomp/others/belt_MapInt.ml +++ b/jscomp/others/belt_MapInt.ml @@ -161,4 +161,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge +let fromArray = I.ofArray let ofArray = I.ofArray diff --git a/jscomp/others/belt_MapInt.mli b/jscomp/others/belt_MapInt.mli index 268de10e88..8df247bc6c 100644 --- a/jscomp/others/belt_MapInt.mli +++ b/jscomp/others/belt_MapInt.mli @@ -47,6 +47,8 @@ val toList: 'v t -> (key * 'v) list (** In increasing order with respect *) val toArray: 'v t -> (key * 'v) array val ofArray: (key * 'v) array -> 'v t +[@@ocaml.deprecated "Use fromArray instead"] +val fromArray: (key * 'v) array -> 'v t val keysToArray: 'v t -> key array val valuesToArray: 'v t -> 'v array val minKey: _ t -> key option diff --git a/jscomp/others/belt_MapString.ml b/jscomp/others/belt_MapString.ml index 5ec9786c3e..93d8e5bff6 100644 --- a/jscomp/others/belt_MapString.ml +++ b/jscomp/others/belt_MapString.ml @@ -161,4 +161,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge +let fromArray = I.ofArray let ofArray = I.ofArray diff --git a/jscomp/others/belt_MapString.mli b/jscomp/others/belt_MapString.mli index 03ead6ec07..d1f70fb284 100644 --- a/jscomp/others/belt_MapString.mli +++ b/jscomp/others/belt_MapString.mli @@ -47,6 +47,8 @@ val toList: 'v t -> (key * 'v) list (** In increasing order with respect *) val toArray: 'v t -> (key * 'v) array val ofArray: (key * 'v) array -> 'v t +[@@ocaml.deprecated "Use fromArray instead"] +val fromArray: (key * 'v) array -> 'v t val keysToArray: 'v t -> key array val valuesToArray: 'v t -> 'v array val minKey: _ t -> key option diff --git a/jscomp/others/belt_MutableMap.ml b/jscomp/others/belt_MutableMap.ml index aebf2ecbb7..9faeaf7fa0 100644 --- a/jscomp/others/belt_MutableMap.ml +++ b/jscomp/others/belt_MutableMap.ml @@ -216,10 +216,12 @@ let getExn m x = let has m x = N.has ~cmp:(S.cmp m) (S.data m) x -let ofArray (type k) (type identity) data ~(id : (k,identity) id)= +let fromArray (type k) (type identity) data ~(id : (k,identity) id)= let module M = (val id ) in let cmp = M.cmp in S.t ~cmp ~data:(N.ofArray ~cmp data) + +let ofArray = fromArray let set m e v = let oldRoot = S.data m in diff --git a/jscomp/others/belt_MutableMap.mli b/jscomp/others/belt_MutableMap.mli index 6b21a88046..f98091f1a5 100644 --- a/jscomp/others/belt_MutableMap.mli +++ b/jscomp/others/belt_MutableMap.mli @@ -140,7 +140,7 @@ val size: ('k, 'a, 'id) t -> int val toList: ('k, 'a, 'id) t -> ('k * 'a) list (** In increasing order*) val toArray: ('k, 'a, 'id) t -> ('k * 'a) array -val ofArray: ('k * 'a) array -> id:('k,'id) id -> ('k,'a,'id) t +val fromArray: ('k * 'a) array -> id:('k,'id) id -> ('k,'a,'id) t val keysToArray: ('k, _, _) t -> 'k array val valuesToArray: (_, 'a, _) t -> 'a array val minKey: ('k, _, _) t -> 'k option @@ -161,6 +161,9 @@ val checkInvariantInternal: _ t -> unit {b raise} when invariant is not held *) +val ofArray: ('k * 'a) array -> id:('k,'id) id -> ('k,'a,'id) t +[@@ocaml.deprecated "Use fromArray instead"] + (****************************************************************************) (*TODO: add functional [merge, partition, keep, split]*) diff --git a/jscomp/others/belt_MutableMapInt.ml b/jscomp/others/belt_MutableMapInt.ml index 661c464bc5..9dd0f4d5f6 100644 --- a/jscomp/others/belt_MutableMapInt.ml +++ b/jscomp/others/belt_MutableMapInt.ml @@ -155,9 +155,11 @@ let removeMany (type key) (type id) (d : _ t) xs = (* let merge = I.merge *) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmpU d0 d1 f = I.cmpU (data d0) (data d1) f let cmp d0 d1 f = cmpU d0 d1 (fun[@bs] a b -> f a b) diff --git a/jscomp/others/belt_MutableMapInt.mli b/jscomp/others/belt_MutableMapInt.mli index 84e3308ac1..0cf401e2c3 100644 --- a/jscomp/others/belt_MutableMapInt.mli +++ b/jscomp/others/belt_MutableMapInt.mli @@ -80,7 +80,11 @@ val size: 'a t -> int val toList: 'a t -> (key * 'a) list (** In increasing order *) val toArray: 'a t -> (key * 'a) array + val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: (key * 'a) array -> 'a t val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array val minKey: _ t -> key option diff --git a/jscomp/others/belt_MutableMapString.ml b/jscomp/others/belt_MutableMapString.ml index a3211e642a..3abc1544d5 100644 --- a/jscomp/others/belt_MutableMapString.ml +++ b/jscomp/others/belt_MutableMapString.ml @@ -155,9 +155,11 @@ let removeMany (type key) (type id) (d : _ t) xs = (* let merge = I.merge *) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmpU d0 d1 f = I.cmpU (data d0) (data d1) f let cmp d0 d1 f = cmpU d0 d1 (fun[@bs] a b -> f a b) diff --git a/jscomp/others/belt_MutableMapString.mli b/jscomp/others/belt_MutableMapString.mli index 72cc19f2ed..7d3ec5dc2b 100644 --- a/jscomp/others/belt_MutableMapString.mli +++ b/jscomp/others/belt_MutableMapString.mli @@ -80,7 +80,11 @@ val size: 'a t -> int val toList: 'a t -> (key * 'a) list (** In increasing order *) val toArray: 'a t -> (key * 'a) array + val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: (key * 'a) array -> 'a t val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array val minKey: _ t -> key option diff --git a/jscomp/others/belt_MutableQueue.ml b/jscomp/others/belt_MutableQueue.ml index 49866b76cc..8ce5333c09 100644 --- a/jscomp/others/belt_MutableQueue.ml +++ b/jscomp/others/belt_MutableQueue.ml @@ -212,10 +212,12 @@ let toArray x = fillAux 0 v (first x); v -(*TODO: optimzie *) -let ofArray arr = +(*TODO: optimize *) +let fromArray arr = let q = make () in for i = 0 to A.length arr - 1 do add q (A.getUnsafe arr i) done ; q + +let ofArray = fromArray diff --git a/jscomp/others/belt_MutableQueue.mli b/jscomp/others/belt_MutableQueue.mli index fc49feaf1a..4c718967ac 100644 --- a/jscomp/others/belt_MutableQueue.mli +++ b/jscomp/others/belt_MutableQueue.mli @@ -31,7 +31,10 @@ val isEmpty: 'a t -> bool (** @return [true] if the given queue is empty, [false] otherwise. *) val ofArray: 'a array -> 'a t -(** [ofArray a] is equivalent to [Array.forEach a (add q a)] *) +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: 'a array -> 'a t +(** [fromArray a] is equivalent to [Array.forEach a (add q a)] *) val add: 'a t -> 'a -> unit (** [add q x] adds the element [x] at the end of the queue [q]. *) diff --git a/jscomp/others/belt_MutableSet.ml b/jscomp/others/belt_MutableSet.ml index e4069876e8..0f960bba55 100644 --- a/jscomp/others/belt_MutableSet.ml +++ b/jscomp/others/belt_MutableSet.ml @@ -220,19 +220,22 @@ let toList d = let toArray d = N.toArray (S.data d) -let ofSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id) : _ t = +let fromSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id) : _ t = let module M = (val id) in S.t ~data:(N.ofSortedArrayUnsafe xs) ~cmp:M.cmp + +let ofSortedArrayUnsafe = fromSortedArrayUnsafe let checkInvariantInternal d = N.checkInvariantInternal (S.data d) -let ofArray (type value) (type identity) data ~(id : (value,identity) id) = +let fromArray (type value) (type identity) data ~(id : (value,identity) id) = let module M = (val id) in let cmp = M.cmp in S.t ~cmp ~data:(N.ofArray ~cmp data) - + +let ofArray = fromArray let cmp d0 d1 = N.cmp ~cmp:(S.cmp d0) (S.data d0) (S.data d1) diff --git a/jscomp/others/belt_MutableSet.mli b/jscomp/others/belt_MutableSet.mli index 146673d983..3c8f7f27b1 100644 --- a/jscomp/others/belt_MutableSet.mli +++ b/jscomp/others/belt_MutableSet.mli @@ -89,8 +89,8 @@ type ('k, 'id) id = ('k, 'id) Belt_Id.comparable val make: id:('value, 'id) id -> ('value, 'id) t -val ofArray: 'k array -> id:('k, 'id) id -> ('k, 'id) t -val ofSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t +val fromArray: 'k array -> id:('k, 'id) id -> ('k, 'id) t +val fromSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t val copy: ('k, 'id) t -> ('k, 'id) t val isEmpty: _ t -> bool val has: ('value, _) t -> 'value -> bool @@ -192,3 +192,9 @@ val checkInvariantInternal: _ t -> unit ('value, 'id) t0] 2. It is not really significantly more *) + +val ofArray: 'k array -> id:('k, 'id) id -> ('k, 'id) t +[@@ocaml.deprecated "Use fromArray instead"] + +val ofSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] diff --git a/jscomp/others/belt_MutableSetInt.ml b/jscomp/others/belt_MutableSetInt.ml index fb5bebbf19..b8bf517bf6 100644 --- a/jscomp/others/belt_MutableSetInt.ml +++ b/jscomp/others/belt_MutableSetInt.ml @@ -217,16 +217,21 @@ let toArray d = N.toArray (data d) -let ofSortedArrayUnsafe xs = +let fromSortedArrayUnsafe xs = t ~data:(N.ofSortedArrayUnsafe xs) + +let ofSortedArrayUnsafe = fromSortedArrayUnsafe + let checkInvariantInternal d = N.checkInvariantInternal (data d) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmp d0 d1 = I.cmp (data d0) (data d1) let eq d0 d1 = diff --git a/jscomp/others/belt_MutableSetInt.mli b/jscomp/others/belt_MutableSetInt.mli index 4193451848..f354b6b8d8 100644 --- a/jscomp/others/belt_MutableSetInt.mli +++ b/jscomp/others/belt_MutableSetInt.mli @@ -43,8 +43,14 @@ type t val make: unit -> t +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t + val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + val copy: t -> t val isEmpty: t -> bool val has: t -> value -> bool diff --git a/jscomp/others/belt_MutableSetString.ml b/jscomp/others/belt_MutableSetString.ml index 9bfc44087b..c0d5681731 100644 --- a/jscomp/others/belt_MutableSetString.ml +++ b/jscomp/others/belt_MutableSetString.ml @@ -217,16 +217,21 @@ let toArray d = N.toArray (data d) -let ofSortedArrayUnsafe xs = +let fromSortedArrayUnsafe xs = t ~data:(N.ofSortedArrayUnsafe xs) + +let ofSortedArrayUnsafe = fromSortedArrayUnsafe + let checkInvariantInternal d = N.checkInvariantInternal (data d) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmp d0 d1 = I.cmp (data d0) (data d1) let eq d0 d1 = diff --git a/jscomp/others/belt_MutableSetString.mli b/jscomp/others/belt_MutableSetString.mli index 274e8cf8d8..27632c8112 100644 --- a/jscomp/others/belt_MutableSetString.mli +++ b/jscomp/others/belt_MutableSetString.mli @@ -43,8 +43,14 @@ type t val make: unit -> t +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t + val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + val copy: t -> t val isEmpty: t -> bool val has: t -> value -> bool diff --git a/jscomp/others/belt_Set.ml b/jscomp/others/belt_Set.ml index 0dd170159d..5a5067b93d 100644 --- a/jscomp/others/belt_Set.ml +++ b/jscomp/others/belt_Set.ml @@ -41,10 +41,12 @@ end type ('value, 'id) t = ('value, 'id) S.t -let ofArray (type value) (type identity) data ~(id : (value,identity) id) = +let fromArray (type value) (type identity) data ~(id : (value,identity) id) = let module M = (val id ) in let cmp = M.cmp in - S.t ~cmp ~data:(Dict.ofArray ~cmp data) + S.t ~cmp ~data:(Dict.fromArray ~cmp data) + +let ofArray = fromArray let remove m e = let cmp, data = S.cmp m, S.data m in @@ -145,11 +147,11 @@ let getExn m e = let has m e = Dict.has ~cmp:(S.cmp m) (S.data m) e -let ofSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id ) = +let fromSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id ) = let module M = (val id) in S.t ~cmp:M.cmp ~data:(Dict.ofSortedArrayUnsafe xs) - +let ofSortedArrayUnsafe = fromSortedArrayUnsafe let getData = S.data diff --git a/jscomp/others/belt_Set.mli b/jscomp/others/belt_Set.mli index a08d7a18ea..8cf85b8b6c 100644 --- a/jscomp/others/belt_Set.mli +++ b/jscomp/others/belt_Set.mli @@ -115,23 +115,29 @@ val make: id:('value, 'id) id -> ('value, 'id) t *) -val ofArray: 'value array -> id:('value, 'id) id -> ('value, 'id) t -(** [ofArray xs ~id] +val ofArray: 'value array -> id:('value, 'id) id -> ('value, 'id) t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: 'value array -> id:('value, 'id) id -> ('value, 'id) t +(** [fromArray xs ~id] @example{[ module IntCmp = (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - toArray (ofArray [1;3;2;4] (module IntCmp)) = [1;2;3;4] + toArray (fromArray [1;3;2;4] (module IntCmp)) = [1;2;3;4] ]} *) val ofSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t -(** [ofSortedArrayUnsafe xs ~id] +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + +val fromSortedArrayUnsafe: 'value array -> id:('value, 'id) id -> ('value,'id) t +(** [fromSortedArrayUnsafe xs ~id] - The same as {!ofArray} except it is after assuming the input array [x] is already sorted + The same as {!fromArray} except it is after assuming the input array [x] is already sorted {b Unsafe} *) @@ -144,8 +150,8 @@ val isEmpty: _ t -> bool (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - isEmpty (ofArray [||] ~id:(module IntCmp)) = true;; - isEmpty (ofArray [|1|] ~id:(module IntCmp)) = true;; + isEmpty (fromArray [||] ~id:(module IntCmp)) = true;; + isEmpty (fromArray [|1|] ~id:(module IntCmp)) = true;; ]} *) val has: ('value, 'id) t -> 'value -> bool @@ -155,7 +161,7 @@ val has: ('value, 'id) t -> 'value -> bool (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let v = ofArray [|1;4;2;5|] ~id:(module IntCmp);; + let v = fromArray [|1;4;2;5|] ~id:(module IntCmp);; has v 3 = false;; has v 1 = true;; ]} @@ -198,7 +204,7 @@ val remove: ('value, 'id) t -> 'value -> ('value, 'id) t (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|2;3;1;4;5|];; + let s0 = fromArray ~id:(module IntCmp) [|2;3;1;4;5|];; let s1 = remove s0 1 ;; let s2 = remove s1 3 ;; let s3 = remove s2 3 ;; @@ -227,8 +233,8 @@ val union: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; - let s1 = ofArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s1 = fromArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; toArray (union s0 s1) = [|1;2;3;4;5;6|] ]} *) @@ -240,8 +246,8 @@ val intersect: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; - let s1 = ofArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s1 = fromArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; toArray (intersect s0 s1) = [|2;3;5|] ]} @@ -253,8 +259,8 @@ val diff: ('value, 'id) t -> ('value, 'id) t -> ('value, 'id) t (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; - let s1 = ofArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s1 = fromArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; toArray (diff s0 s1) = [|6|];; toArray (diff s1 s0) = [|1;4|];; ]} @@ -268,8 +274,8 @@ val subset: ('value, 'id) t -> ('value, 'id) t -> bool (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; - let s1 = ofArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s1 = fromArray ~id:(module IntCmp) [|5;2;3;1;5;4;|];; let s2 = intersect s0 s1;; subset s2 s0 = true;; subset s2 s1 = true;; @@ -300,7 +306,7 @@ val forEach: ('value, 'id) t -> ('value -> unit ) -> unit (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; let acc = ref [] ;; forEach s0 (fun x -> acc := x !acc);; !acc = [6;5;3;2];; @@ -316,7 +322,7 @@ val reduce: ('value, 'id) t -> 'a -> ('a -> 'value -> 'a ) -> 'a (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; reduce s0 [] Bs.List.add = [6;5;3;2];; ]} *) @@ -352,7 +358,7 @@ val size: ('value, 'id) t -> int (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; size s0 = 4;; ]} *) @@ -364,7 +370,7 @@ val toArray: ('value, 'id) t -> 'value array (val Belt.Id.comparableU (fun[\@bs] (x:int) y -> Pervasives.compare x y));; - let s0 = ofArray ~id:(module IntCmp) [|5;2;3;5;6|]];; + let s0 = fromArray ~id:(module IntCmp) [|5;2;3;5;6|]];; toArray s0 = [|2;3;5;6|];; ]}*) diff --git a/jscomp/others/belt_SetDict.ml b/jscomp/others/belt_SetDict.ml index 120121f716..fc581eb45e 100644 --- a/jscomp/others/belt_SetDict.ml +++ b/jscomp/others/belt_SetDict.ml @@ -199,6 +199,7 @@ let rec diff s1 s2 ~cmp = let empty = N.empty +let fromArray = N.ofArray let ofArray = N.ofArray let isEmpty = N.isEmpty diff --git a/jscomp/others/belt_SetDict.mli b/jscomp/others/belt_SetDict.mli index 46ef92fa6e..d019976eb6 100644 --- a/jscomp/others/belt_SetDict.mli +++ b/jscomp/others/belt_SetDict.mli @@ -28,10 +28,10 @@ type ('key, 'id) cmp = ('key, 'id) Belt_Id.cmp val empty: ('value, 'id) t -val ofArray: - 'k array -> - cmp:('k, 'id) cmp -> - ('k, 'id) t +val ofArray: 'k array -> cmp:('k, 'id) cmp -> ('k, 'id) t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: 'k array -> cmp:('k, 'id) cmp -> ('k, 'id) t val ofSortedArrayUnsafe: 'value array -> ('value,'id) t diff --git a/jscomp/others/hashmap.cppo.ml b/jscomp/others/hashmap.cppo.ml index 28a6c69d78..e247e70e86 100644 --- a/jscomp/others/hashmap.cppo.ml +++ b/jscomp/others/hashmap.cppo.ml @@ -195,7 +195,7 @@ let valuesToArray = N.valuesToArray let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = make len in for i = 0 to len - 1 do @@ -204,6 +204,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/hashmap.cppo.mli b/jscomp/others/hashmap.cppo.mli index 57a023d1da..5ce40573dd 100644 --- a/jscomp/others/hashmap.cppo.mli +++ b/jscomp/others/hashmap.cppo.mli @@ -46,7 +46,10 @@ val size: _ t -> int val toArray: 'a t -> (key * 'a) array val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array -val ofArray: (key * 'a) array -> 'a t +val fromArray: (key * 'a) array -> 'a t val mergeMany: 'a t -> (key * 'a) array -> unit val getBucketHistogram: _ t -> int array val logStats: _ t -> unit + +val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] diff --git a/jscomp/others/hashset.cppo.ml b/jscomp/others/hashset.cppo.ml index 12d35ffa24..8fa3a8280c 100644 --- a/jscomp/others/hashset.cppo.ml +++ b/jscomp/others/hashset.cppo.ml @@ -148,7 +148,7 @@ let copy = N.copy let getBucketHistogram = N.getBucketHistogram let isEmpty = C.isEmpty -let ofArray arr = +let fromArray arr = let len = A.length arr in let v = C.make ~hintSize:len ~hash:() ~eq:() in for i = 0 to len - 1 do @@ -156,6 +156,8 @@ let ofArray arr = done ; v +let ofArray = fromArray + (* TOOD: optimize heuristics for resizing *) let mergeMany h arr = let len = A.length arr in diff --git a/jscomp/others/hashset.cppo.mli b/jscomp/others/hashset.cppo.mli index b737255e05..dd8042da3a 100644 --- a/jscomp/others/hashset.cppo.mli +++ b/jscomp/others/hashset.cppo.mli @@ -70,6 +70,9 @@ val logStats: t -> unit val toArray: t -> key array val ofArray: key array -> t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: key array -> t val mergeMany: t -> key array -> unit diff --git a/jscomp/others/map.cppo.ml b/jscomp/others/map.cppo.ml index 1e2451cdfc..164288812c 100644 --- a/jscomp/others/map.cppo.ml +++ b/jscomp/others/map.cppo.ml @@ -166,4 +166,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge +let fromArray = I.ofArray let ofArray = I.ofArray diff --git a/jscomp/others/map.cppo.mli b/jscomp/others/map.cppo.mli index a6a5f05013..2efdd39590 100644 --- a/jscomp/others/map.cppo.mli +++ b/jscomp/others/map.cppo.mli @@ -51,6 +51,8 @@ val toList: 'v t -> (key * 'v) list (** In increasing order with respect *) val toArray: 'v t -> (key * 'v) array val ofArray: (key * 'v) array -> 'v t +[@@ocaml.deprecated "Use fromArray instead"] +val fromArray: (key * 'v) array -> 'v t val keysToArray: 'v t -> key array val valuesToArray: 'v t -> 'v array val minKey: _ t -> key option diff --git a/jscomp/others/mapm.cppo.ml b/jscomp/others/mapm.cppo.ml index e296b85270..f20573b370 100644 --- a/jscomp/others/mapm.cppo.ml +++ b/jscomp/others/mapm.cppo.ml @@ -160,9 +160,11 @@ let removeMany (type key) (type id) (d : _ t) xs = (* let merge = I.merge *) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmpU d0 d1 f = I.cmpU (data d0) (data d1) f let cmp d0 d1 f = cmpU d0 d1 (fun[@bs] a b -> f a b) diff --git a/jscomp/others/mapm.cppo.mli b/jscomp/others/mapm.cppo.mli index 670d1bb638..fb7a694766 100644 --- a/jscomp/others/mapm.cppo.mli +++ b/jscomp/others/mapm.cppo.mli @@ -83,7 +83,11 @@ val size: 'a t -> int val toList: 'a t -> (key * 'a) list (** In increasing order *) val toArray: 'a t -> (key * 'a) array + val ofArray: (key * 'a) array -> 'a t +[@@ocaml.deprecated "Use fromArray instead"] + +val fromArray: (key * 'a) array -> 'a t val keysToArray: 'a t -> key array val valuesToArray: 'a t -> 'a array val minKey: _ t -> key option diff --git a/jscomp/others/setm.cppo.ml b/jscomp/others/setm.cppo.ml index d30073bdff..8a7453e488 100644 --- a/jscomp/others/setm.cppo.ml +++ b/jscomp/others/setm.cppo.ml @@ -221,16 +221,21 @@ let toArray d = N.toArray (data d) -let ofSortedArrayUnsafe xs = +let fromSortedArrayUnsafe xs = t ~data:(N.ofSortedArrayUnsafe xs) + +let ofSortedArrayUnsafe = fromSortedArrayUnsafe + let checkInvariantInternal d = N.checkInvariantInternal (data d) -let ofArray xs = +let fromArray xs = t ~data:(I.ofArray xs) +let ofArray = fromArray + let cmp d0 d1 = I.cmp (data d0) (data d1) let eq d0 d1 = diff --git a/jscomp/others/setm.cppo.mli b/jscomp/others/setm.cppo.mli index 58311f498e..dff7322a14 100644 --- a/jscomp/others/setm.cppo.mli +++ b/jscomp/others/setm.cppo.mli @@ -46,8 +46,14 @@ type t val make: unit -> t +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t + val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + val copy: t -> t val isEmpty: t -> bool val has: t -> value -> bool From d5ceb500f761e870252964a5182a059999bfdeb0 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 7 Mar 2018 21:26:59 -0800 Subject: [PATCH 2/5] Change internal ofFoo to fromFoo too --- jscomp/others/belt_MapDict.ml | 4 ++-- jscomp/others/belt_MapInt.ml | 4 ++-- jscomp/others/belt_MapString.ml | 4 ++-- jscomp/others/belt_MutableMap.ml | 6 +++--- jscomp/others/belt_MutableMapInt.ml | 2 +- jscomp/others/belt_MutableMapString.ml | 2 +- jscomp/others/belt_MutableSet.ml | 20 +++++++++--------- jscomp/others/belt_MutableSetInt.ml | 20 +++++++++--------- jscomp/others/belt_MutableSetString.ml | 20 +++++++++--------- jscomp/others/belt_Set.ml | 2 +- jscomp/others/belt_SetDict.ml | 7 ++++--- jscomp/others/belt_SetDict.mli | 4 +++- jscomp/others/belt_SetInt.ml | 6 ++++-- jscomp/others/belt_SetInt.mli | 5 +++++ jscomp/others/belt_SetString.ml | 6 ++++-- jscomp/others/belt_SetString.mli | 5 +++++ jscomp/others/belt_internalAVLset.ml | 28 ++++++++++++------------- jscomp/others/belt_internalAVLset.mli | 8 +++---- jscomp/others/belt_internalAVLtree.ml | 22 +++++++++---------- jscomp/others/belt_internalAVLtree.mli | 8 +++---- jscomp/others/belt_internalMapInt.ml | 6 +++--- jscomp/others/belt_internalMapString.ml | 6 +++--- jscomp/others/belt_internalSetInt.ml | 6 +++--- jscomp/others/belt_internalSetString.ml | 6 +++--- jscomp/others/internal_map.cppo.ml | 6 +++--- jscomp/others/internal_set.cppo.ml | 6 +++--- jscomp/others/map.cppo.ml | 4 ++-- jscomp/others/mapm.cppo.ml | 2 +- jscomp/others/set.cppo.ml | 6 ++++-- jscomp/others/set.cppo.mli | 5 +++++ jscomp/others/setm.cppo.ml | 20 +++++++++--------- 31 files changed, 140 insertions(+), 116 deletions(-) diff --git a/jscomp/others/belt_MapDict.ml b/jscomp/others/belt_MapDict.ml index bac2c07e14..37f58aad53 100644 --- a/jscomp/others/belt_MapDict.ml +++ b/jscomp/others/belt_MapDict.ml @@ -30,8 +30,8 @@ type ('key, 'a, 'id) t = ('key, 'a) N.t type ('key, 'id) cmp = ('key, 'id) Belt_Id.cmp let empty = N.empty -let fromArray = N.ofArray -let ofArray = N.ofArray +let fromArray = N.fromArray +let ofArray = N.fromArray let isEmpty = N.isEmpty let cmp = N.cmp let cmpU = N.cmpU diff --git a/jscomp/others/belt_MapInt.ml b/jscomp/others/belt_MapInt.ml index 8c5ee023e5..e635b74d43 100644 --- a/jscomp/others/belt_MapInt.ml +++ b/jscomp/others/belt_MapInt.ml @@ -161,5 +161,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge -let fromArray = I.ofArray -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray diff --git a/jscomp/others/belt_MapString.ml b/jscomp/others/belt_MapString.ml index 93d8e5bff6..1ccad9d929 100644 --- a/jscomp/others/belt_MapString.ml +++ b/jscomp/others/belt_MapString.ml @@ -161,5 +161,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge -let fromArray = I.ofArray -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray diff --git a/jscomp/others/belt_MutableMap.ml b/jscomp/others/belt_MutableMap.ml index 9faeaf7fa0..d9e94368e5 100644 --- a/jscomp/others/belt_MutableMap.ml +++ b/jscomp/others/belt_MutableMap.ml @@ -180,9 +180,9 @@ let keysToArray d = let valuesToArray d = N.valuesToArray (S.data d) -let ofSortedArrayUnsafe (type key) (type identity) ~(id : (key,identity) id) xs : _ t = +let fromSortedArrayUnsafe (type key) (type identity) ~(id : (key,identity) id) xs : _ t = let module M = (val id) in - S.t ~data:(N.ofSortedArrayUnsafe xs) ~cmp:M.cmp + S.t ~data:(N.fromSortedArrayUnsafe xs) ~cmp:M.cmp let checkInvariantInternal d = N.checkInvariantInternal (S.data d) @@ -219,7 +219,7 @@ let has m x = let fromArray (type k) (type identity) data ~(id : (k,identity) id)= let module M = (val id ) in let cmp = M.cmp in - S.t ~cmp ~data:(N.ofArray ~cmp data) + S.t ~cmp ~data:(N.fromArray ~cmp data) let ofArray = fromArray diff --git a/jscomp/others/belt_MutableMapInt.ml b/jscomp/others/belt_MutableMapInt.ml index 9dd0f4d5f6..d9729cb7d4 100644 --- a/jscomp/others/belt_MutableMapInt.ml +++ b/jscomp/others/belt_MutableMapInt.ml @@ -156,7 +156,7 @@ let removeMany (type key) (type id) (d : _ t) xs = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray diff --git a/jscomp/others/belt_MutableMapString.ml b/jscomp/others/belt_MutableMapString.ml index 3abc1544d5..38e98e612f 100644 --- a/jscomp/others/belt_MutableMapString.ml +++ b/jscomp/others/belt_MutableMapString.ml @@ -156,7 +156,7 @@ let removeMany (type key) (type id) (d : _ t) xs = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray diff --git a/jscomp/others/belt_MutableSet.ml b/jscomp/others/belt_MutableSet.ml index 0f960bba55..83c42ebfa3 100644 --- a/jscomp/others/belt_MutableSet.ml +++ b/jscomp/others/belt_MutableSet.ml @@ -222,7 +222,7 @@ let toArray d = let fromSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id) : _ t = let module M = (val id) in - S.t ~data:(N.ofSortedArrayUnsafe xs) ~cmp:M.cmp + S.t ~data:(N.fromSortedArrayUnsafe xs) ~cmp:M.cmp let ofSortedArrayUnsafe = fromSortedArrayUnsafe @@ -233,7 +233,7 @@ let checkInvariantInternal d = let fromArray (type value) (type identity) data ~(id : (value,identity) id) = let module M = (val id) in let cmp = M.cmp in - S.t ~cmp ~data:(N.ofArray ~cmp data) + S.t ~cmp ~data:(N.fromArray ~cmp data) let ofArray = fromArray @@ -261,19 +261,19 @@ let split d key = if i < 0 then let next = - i -1 in (S.t - ~data:(N.ofSortedArrayAux arr 0 next) + ~data:(N.fromSortedArrayAux arr 0 next) ~cmp , S.t - ~data:(N.ofSortedArrayAux arr next (len - next)) + ~data:(N.fromSortedArrayAux arr next (len - next)) ~cmp ), false else (S.t - ~data:(N.ofSortedArrayAux arr 0 i) + ~data:(N.fromSortedArrayAux arr 0 i) ~cmp, S.t - ~data:(N.ofSortedArrayAux arr (i+1) (len - i - 1)) + ~data:(N.fromSortedArrayAux arr (i+1) (len - i - 1)) ~cmp ), true @@ -316,7 +316,7 @@ let intersect a b : _ t = else let tmp2 = A.makeUninitializedUnsafe (min sizea sizeb) in let k = Sort.intersectU tmp 0 sizea tmp sizea sizeb tmp2 0 p in - S.t ~data:(N.ofSortedArrayAux tmp2 0 k) + S.t ~data:(N.fromSortedArrayAux tmp2 0 k) ~cmp let diff a b : _ t = @@ -345,7 +345,7 @@ let diff a b : _ t = else let tmp2 = A.makeUninitializedUnsafe sizea in let k = Sort.diffU tmp 0 sizea tmp sizea sizeb tmp2 0 p in - S.t ~data:(N.ofSortedArrayAux tmp2 0 k) ~cmp + S.t ~data:(N.fromSortedArrayAux tmp2 0 k) ~cmp let union a b = let cmp = S.cmp a in @@ -364,11 +364,11 @@ let union a b = if p (A.getUnsafe tmp (sizea - 1)) (A.getUnsafe tmp sizea) [@bs] < 0 then - S.t ~data:(N.ofSortedArrayAux tmp 0 totalSize) ~cmp + S.t ~data:(N.fromSortedArrayAux tmp 0 totalSize) ~cmp else let tmp2 = A.makeUninitializedUnsafe totalSize in let k = Sort.unionU tmp 0 sizea tmp sizea sizeb tmp2 0 p in - S.t ~data:(N.ofSortedArrayAux tmp2 0 k) ~cmp + S.t ~data:(N.fromSortedArrayAux tmp2 0 k) ~cmp let has d x = N.has ~cmp:(S.cmp d) (S.data d) x diff --git a/jscomp/others/belt_MutableSetInt.ml b/jscomp/others/belt_MutableSetInt.ml index b8bf517bf6..0d719db940 100644 --- a/jscomp/others/belt_MutableSetInt.ml +++ b/jscomp/others/belt_MutableSetInt.ml @@ -218,7 +218,7 @@ let toArray d = let fromSortedArrayUnsafe xs = - t ~data:(N.ofSortedArrayUnsafe xs) + t ~data:(N.fromSortedArrayUnsafe xs) let ofSortedArrayUnsafe = fromSortedArrayUnsafe @@ -228,7 +228,7 @@ let checkInvariantInternal d = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray @@ -250,17 +250,17 @@ let split d key = if i < 0 then let next = - i -1 in (t - ~data:(N.ofSortedArrayAux arr 0 next) + ~data:(N.fromSortedArrayAux arr 0 next) , t - ~data:(N.ofSortedArrayAux arr next (len - next)) + ~data:(N.fromSortedArrayAux arr next (len - next)) ), false else (t - ~data:(N.ofSortedArrayAux arr 0 i) + ~data:(N.fromSortedArrayAux arr 0 i) , t - ~data:(N.ofSortedArrayAux arr (i+1) (len - i - 1)) + ~data:(N.fromSortedArrayAux arr (i+1) (len - i - 1)) ), true let keepU d p = @@ -296,7 +296,7 @@ let intersect dataa datab = else let tmp2 = A.makeUninitializedUnsafe (min sizea sizeb) in let k = S.intersect tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let diff dataa datab : t = let dataa, datab = data dataa, data datab in @@ -318,7 +318,7 @@ let diff dataa datab : t = else let tmp2 = A.makeUninitializedUnsafe sizea in let k = S.diff tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let union (dataa : t) (datab : t) : t = let dataa, datab = data dataa, data datab in @@ -335,11 +335,11 @@ let union (dataa : t) (datab : t) : t = if (A.getUnsafe tmp (sizea - 1) < A.getUnsafe tmp sizea) then - t ~data:(N.ofSortedArrayAux tmp 0 totalSize) + t ~data:(N.fromSortedArrayAux tmp 0 totalSize) else let tmp2 = A.makeUninitializedUnsafe totalSize in let k = S.union tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let has d x = I.has (data d) x diff --git a/jscomp/others/belt_MutableSetString.ml b/jscomp/others/belt_MutableSetString.ml index c0d5681731..ee27bb01f3 100644 --- a/jscomp/others/belt_MutableSetString.ml +++ b/jscomp/others/belt_MutableSetString.ml @@ -218,7 +218,7 @@ let toArray d = let fromSortedArrayUnsafe xs = - t ~data:(N.ofSortedArrayUnsafe xs) + t ~data:(N.fromSortedArrayUnsafe xs) let ofSortedArrayUnsafe = fromSortedArrayUnsafe @@ -228,7 +228,7 @@ let checkInvariantInternal d = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray @@ -250,17 +250,17 @@ let split d key = if i < 0 then let next = - i -1 in (t - ~data:(N.ofSortedArrayAux arr 0 next) + ~data:(N.fromSortedArrayAux arr 0 next) , t - ~data:(N.ofSortedArrayAux arr next (len - next)) + ~data:(N.fromSortedArrayAux arr next (len - next)) ), false else (t - ~data:(N.ofSortedArrayAux arr 0 i) + ~data:(N.fromSortedArrayAux arr 0 i) , t - ~data:(N.ofSortedArrayAux arr (i+1) (len - i - 1)) + ~data:(N.fromSortedArrayAux arr (i+1) (len - i - 1)) ), true let keepU d p = @@ -296,7 +296,7 @@ let intersect dataa datab = else let tmp2 = A.makeUninitializedUnsafe (min sizea sizeb) in let k = S.intersect tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let diff dataa datab : t = let dataa, datab = data dataa, data datab in @@ -318,7 +318,7 @@ let diff dataa datab : t = else let tmp2 = A.makeUninitializedUnsafe sizea in let k = S.diff tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let union (dataa : t) (datab : t) : t = let dataa, datab = data dataa, data datab in @@ -335,11 +335,11 @@ let union (dataa : t) (datab : t) : t = if (A.getUnsafe tmp (sizea - 1) < A.getUnsafe tmp sizea) then - t ~data:(N.ofSortedArrayAux tmp 0 totalSize) + t ~data:(N.fromSortedArrayAux tmp 0 totalSize) else let tmp2 = A.makeUninitializedUnsafe totalSize in let k = S.union tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let has d x = I.has (data d) x diff --git a/jscomp/others/belt_Set.ml b/jscomp/others/belt_Set.ml index 5a5067b93d..8f3620b182 100644 --- a/jscomp/others/belt_Set.ml +++ b/jscomp/others/belt_Set.ml @@ -149,7 +149,7 @@ let has m e = let fromSortedArrayUnsafe (type value) (type identity) xs ~(id : (value,identity) id ) = let module M = (val id) in - S.t ~cmp:M.cmp ~data:(Dict.ofSortedArrayUnsafe xs) + S.t ~cmp:M.cmp ~data:(Dict.fromSortedArrayUnsafe xs) let ofSortedArrayUnsafe = fromSortedArrayUnsafe diff --git a/jscomp/others/belt_SetDict.ml b/jscomp/others/belt_SetDict.ml index fc581eb45e..f6d04d6458 100644 --- a/jscomp/others/belt_SetDict.ml +++ b/jscomp/others/belt_SetDict.ml @@ -199,8 +199,8 @@ let rec diff s1 s2 ~cmp = let empty = N.empty -let fromArray = N.ofArray -let ofArray = N.ofArray +let fromArray = N.fromArray +let ofArray = N.fromArray let isEmpty = N.isEmpty @@ -228,7 +228,8 @@ let getExn = N.getExn let getUndefined = N.getUndefined -let ofSortedArrayUnsafe = N.ofSortedArrayUnsafe +let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe +let ofSortedArrayUnsafe = N.fromSortedArrayUnsafe let subset = N.subset let keep = N.keepShared let keepU = N.keepSharedU diff --git a/jscomp/others/belt_SetDict.mli b/jscomp/others/belt_SetDict.mli index d019976eb6..95629b96e6 100644 --- a/jscomp/others/belt_SetDict.mli +++ b/jscomp/others/belt_SetDict.mli @@ -30,10 +30,12 @@ val empty: ('value, 'id) t val ofArray: 'k array -> cmp:('k, 'id) cmp -> ('k, 'id) t [@@ocaml.deprecated "Use fromArray instead"] +val ofSortedArrayUnsafe: 'value array -> ('value,'id) t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] val fromArray: 'k array -> cmp:('k, 'id) cmp -> ('k, 'id) t -val ofSortedArrayUnsafe: 'value array -> ('value,'id) t +val fromSortedArrayUnsafe: 'value array -> ('value,'id) t val isEmpty: _ t -> bool val has: diff --git a/jscomp/others/belt_SetInt.ml b/jscomp/others/belt_SetInt.ml index caf18b992c..1103cce085 100644 --- a/jscomp/others/belt_SetInt.ml +++ b/jscomp/others/belt_SetInt.ml @@ -31,7 +31,8 @@ let partitionU = N.partitionSharedU let size = N.size let toList = N.toList let toArray = N.toArray -let ofSortedArrayUnsafe = N.ofSortedArrayUnsafe +let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe +let ofSortedArrayUnsafe = N.fromSortedArrayUnsafe let checkInvariantInternal = N.checkInvariantInternal let rec add (t : t) (x : value) : t = @@ -92,7 +93,8 @@ let removeMany h arr = done ; !v -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray let cmp = I.cmp let eq = I.eq let get = I.get diff --git a/jscomp/others/belt_SetInt.mli b/jscomp/others/belt_SetInt.mli index 5b56fbc237..2c6ae19856 100644 --- a/jscomp/others/belt_SetInt.mli +++ b/jscomp/others/belt_SetInt.mli @@ -43,7 +43,12 @@ val empty: t val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t val isEmpty: t -> bool val has: t -> value -> bool diff --git a/jscomp/others/belt_SetString.ml b/jscomp/others/belt_SetString.ml index 4c6e55baa7..83912ab00a 100644 --- a/jscomp/others/belt_SetString.ml +++ b/jscomp/others/belt_SetString.ml @@ -31,7 +31,8 @@ let partitionU = N.partitionSharedU let size = N.size let toList = N.toList let toArray = N.toArray -let ofSortedArrayUnsafe = N.ofSortedArrayUnsafe +let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe +let ofSortedArrayUnsafe = N.fromSortedArrayUnsafe let checkInvariantInternal = N.checkInvariantInternal let rec add (t : t) (x : value) : t = @@ -92,7 +93,8 @@ let removeMany h arr = done ; !v -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray let cmp = I.cmp let eq = I.eq let get = I.get diff --git a/jscomp/others/belt_SetString.mli b/jscomp/others/belt_SetString.mli index a4808743f5..881d397ce6 100644 --- a/jscomp/others/belt_SetString.mli +++ b/jscomp/others/belt_SetString.mli @@ -43,7 +43,12 @@ val empty: t val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t val isEmpty: t -> bool val has: t -> value -> bool diff --git a/jscomp/others/belt_internalAVLset.ml b/jscomp/others/belt_internalAVLset.ml index 3a707fd49f..c2b37b2724 100644 --- a/jscomp/others/belt_internalAVLset.ml +++ b/jscomp/others/belt_internalAVLset.ml @@ -370,7 +370,7 @@ let toArray n = ignore (fillArray n 0 v : int); (* may add assertion *) v -let rec ofSortedArrayRevAux arr off len = +let rec fromSortedArrayRevAux arr off len = match len with | 0 -> empty | 1 -> singleton (A.getUnsafe arr off) @@ -389,14 +389,14 @@ let rec ofSortedArrayRevAux arr off len = ~height:2 | _ -> let nl = len / 2 in - let left = ofSortedArrayRevAux arr off nl in + let left = fromSortedArrayRevAux arr off nl in let mid = A.getUnsafe arr (off - nl) in let right = - ofSortedArrayRevAux arr (off - nl - 1) (len - nl - 1) in + fromSortedArrayRevAux arr (off - nl - 1) (len - nl - 1) in create left mid right -let rec ofSortedArrayAux arr off len = +let rec fromSortedArrayAux arr off len = match len with | 0 -> empty | 1 -> singleton (A.getUnsafe arr off) @@ -415,14 +415,14 @@ let rec ofSortedArrayAux arr off len = ~height:2 | _ -> let nl = len / 2 in - let left = ofSortedArrayAux arr off nl in + let left = fromSortedArrayAux arr off nl in let mid = A.getUnsafe arr (off + nl) in let right = - ofSortedArrayAux arr (off + nl + 1) (len - nl - 1) in + fromSortedArrayAux arr (off + nl + 1) (len - nl - 1) in create left mid right -let ofSortedArrayUnsafe arr = - ofSortedArrayAux arr 0 (A.length arr) +let fromSortedArrayUnsafe arr = + fromSortedArrayAux arr 0 (A.length arr) let rec keepSharedU n p = match toOpt n with @@ -452,7 +452,7 @@ let keepCopyU n p : _ t = let v = A.makeUninitializedUnsafe size in let last = fillArrayWithFilter n 0 v p in - ofSortedArrayAux v 0 last + fromSortedArrayAux v 0 last let keepCopy n p = keepCopyU n (fun [@bs] x -> p x) @@ -466,8 +466,8 @@ let partitionCopyU n p = let cursor = cursor ~forward:0 ~backward in fillArrayWithPartition n cursor v p ; let forwardLen = forward cursor in - ofSortedArrayAux v 0 forwardLen, - ofSortedArrayRevAux v backward (size - forwardLen) + fromSortedArrayAux v 0 forwardLen, + fromSortedArrayRevAux v backward (size - forwardLen) let partitionCopy n p = partitionCopyU n (fun[@bs] a -> p a) @@ -636,7 +636,7 @@ let rec addMutate ~cmp (t : _ t) x = return (balMutate nt) -let ofArray (xs : _ array) ~cmp = +let fromArray (xs : _ array) ~cmp = let len = A.length xs in if len = 0 then empty else @@ -644,10 +644,10 @@ let ofArray (xs : _ array) ~cmp = (fun [@bs] x y -> (Belt_Id.getCmpInternal cmp) x y [@bs] < 0)) in let result = ref (if !next >= 0 then - ofSortedArrayAux xs 0 !next + fromSortedArrayAux xs 0 !next else begin next := - !next ; - ofSortedArrayRevAux xs (!next - 1) !next + fromSortedArrayRevAux xs (!next - 1) !next end) in for i = !next to len - 1 do result := addMutate ~cmp !result (A.getUnsafe xs i) diff --git a/jscomp/others/belt_internalAVLset.mli b/jscomp/others/belt_internalAVLset.mli index 6eb0f64638..5120d6a99d 100644 --- a/jscomp/others/belt_internalAVLset.mli +++ b/jscomp/others/belt_internalAVLset.mli @@ -101,9 +101,9 @@ val checkInvariantInternal: _ t -> unit *) val fillArray: 'a node -> int -> 'a array -> int val toArray: 'a t -> 'a array -val ofSortedArrayAux : 'a array -> int -> int -> 'a t -val ofSortedArrayRevAux : 'a array -> int -> int -> 'a t -val ofSortedArrayUnsafe : 'a array -> 'a t +val fromSortedArrayAux : 'a array -> int -> int -> 'a t +val fromSortedArrayRevAux : 'a array -> int -> int -> 'a t +val fromSortedArrayUnsafe : 'a array -> 'a t val has: 'a t -> 'a -> cmp:('a, 'b) cmp -> bool val cmp: 'a t -> 'a t -> cmp:('a, 'b) cmp -> int val eq: 'a t -> 'a t -> cmp:('a, 'b) cmp -> bool @@ -113,7 +113,7 @@ val getUndefined: 'a t -> 'a -> cmp:('a, 'b) cmp -> 'a Js.undefined val getExn: 'a t -> 'a -> cmp:('a, 'b) cmp -> 'a -val ofArray: 'a array -> cmp:('a, 'b) cmp -> 'a t +val fromArray: 'a array -> cmp:('a, 'b) cmp -> 'a t val addMutate : cmp:('a, 'b) cmp -> 'a t -> 'a -> 'a t diff --git a/jscomp/others/belt_internalAVLtree.ml b/jscomp/others/belt_internalAVLtree.ml index daba501bdd..b0060bb574 100644 --- a/jscomp/others/belt_internalAVLtree.ml +++ b/jscomp/others/belt_internalAVLtree.ml @@ -482,7 +482,7 @@ let valuesToArray n = ignore (fillArrayValue n 0 v : int); (* may add assertion *) v -let rec ofSortedArrayRevAux arr off len = +let rec fromSortedArrayRevAux arr off len = match len with | 0 -> empty | 1 -> let k, v = (A.getUnsafe arr off) in singleton k v @@ -502,14 +502,14 @@ let rec ofSortedArrayRevAux arr off len = ~height:2 | _ -> let nl = len / 2 in - let left = ofSortedArrayRevAux arr off nl in + let left = fromSortedArrayRevAux arr off nl in let midK,midV = A.getUnsafe arr (off - nl) in let right = - ofSortedArrayRevAux arr (off - nl - 1) (len - nl - 1) in + fromSortedArrayRevAux arr (off - nl - 1) (len - nl - 1) in create left midK midV right -let rec ofSortedArrayAux arr off len = +let rec fromSortedArrayAux arr off len = match len with | 0 -> empty | 1 -> let k, v = (A.getUnsafe arr off) in singleton k v @@ -528,14 +528,14 @@ let rec ofSortedArrayAux arr off len = ~height:2 | _ -> let nl = len / 2 in - let left = ofSortedArrayAux arr off nl in + let left = fromSortedArrayAux arr off nl in let midK, midV = A.getUnsafe arr (off + nl) in let right = - ofSortedArrayAux arr (off + nl + 1) (len - nl - 1) in + fromSortedArrayAux arr (off + nl + 1) (len - nl - 1) in create left midK midV right -let ofSortedArrayUnsafe arr = - ofSortedArrayAux arr 0 (A.length arr) +let fromSortedArrayUnsafe arr = + fromSortedArrayAux arr 0 (A.length arr) let rec compareAux e1 e2 ~kcmp ~vcmp = match e1,e2 with @@ -717,7 +717,7 @@ let rec updateMutate (t : _ t) x data ~cmp = ); return (balMutate nt) -let ofArray (xs : _ array) ~cmp = +let fromArray (xs : _ array) ~cmp = let len = A.length xs in if len = 0 then empty else @@ -729,10 +729,10 @@ let ofArray (xs : _ array) ~cmp = in let result = ref ( if !next >= 0 then - ofSortedArrayAux xs 0 !next + fromSortedArrayAux xs 0 !next else begin next := - !next; - ofSortedArrayRevAux xs (!next - 1) (!next) + fromSortedArrayRevAux xs (!next - 1) (!next) end ) in for i = !next to len - 1 do diff --git a/jscomp/others/belt_internalAVLtree.mli b/jscomp/others/belt_internalAVLtree.mli index 2df5a7d8a8..f8bf69da7b 100644 --- a/jscomp/others/belt_internalAVLtree.mli +++ b/jscomp/others/belt_internalAVLtree.mli @@ -140,9 +140,9 @@ val fillArray : ('a,'b) node -> int -> ('a * 'b) array -> int val toArray : ('a, 'b) t -> ('a * 'b) array val keysToArray : ('a, 'b) t -> 'a array val valuesToArray : ('a, 'b) t -> 'b array -val ofSortedArrayAux : ('a * 'b) array -> int -> int -> ('a, 'b) t -val ofSortedArrayRevAux : ('a * 'b) array -> int -> int -> ('a, 'b) t -val ofSortedArrayUnsafe : ('a * 'b) array -> ('a, 'b) t +val fromSortedArrayAux : ('a * 'b) array -> int -> int -> ('a, 'b) t +val fromSortedArrayRevAux : ('a * 'b) array -> int -> int -> ('a, 'b) t +val fromSortedArrayUnsafe : ('a * 'b) array -> ('a, 'b) t val cmpU: ('a, 'b) t -> ('a, 'c) t -> @@ -200,7 +200,7 @@ val has: -val ofArray : ('a * 'b) array -> cmp:('a,'id) cmp -> ('a, 'b) t +val fromArray : ('a * 'b) array -> cmp:('a,'id) cmp -> ('a, 'b) t val updateMutate : ('a, 'b) t -> 'a -> 'b -> diff --git a/jscomp/others/belt_internalMapInt.ml b/jscomp/others/belt_internalMapInt.ml index 3a410b4cc4..bd1091f829 100644 --- a/jscomp/others/belt_internalMapInt.ml +++ b/jscomp/others/belt_internalMapInt.ml @@ -195,7 +195,7 @@ let rec addMutate (t : _ t) x data : _ t = ); N.return (N.balMutate nt) -let ofArray (xs : (key * _) array) = +let fromArray (xs : (key * _) array) = let len = A.length xs in if len = 0 then N.empty else @@ -207,10 +207,10 @@ let ofArray (xs : (key * _) array) = in let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next; - N.ofSortedArrayRevAux xs (!next - 1) (!next) + N.fromSortedArrayRevAux xs (!next - 1) (!next) end ) in for i = !next to len - 1 do diff --git a/jscomp/others/belt_internalMapString.ml b/jscomp/others/belt_internalMapString.ml index d5c39a420d..083f320ccb 100644 --- a/jscomp/others/belt_internalMapString.ml +++ b/jscomp/others/belt_internalMapString.ml @@ -195,7 +195,7 @@ let rec addMutate (t : _ t) x data : _ t = ); N.return (N.balMutate nt) -let ofArray (xs : (key * _) array) = +let fromArray (xs : (key * _) array) = let len = A.length xs in if len = 0 then N.empty else @@ -207,10 +207,10 @@ let ofArray (xs : (key * _) array) = in let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next; - N.ofSortedArrayRevAux xs (!next - 1) (!next) + N.fromSortedArrayRevAux xs (!next - 1) (!next) end ) in for i = !next to len - 1 do diff --git a/jscomp/others/belt_internalSetInt.ml b/jscomp/others/belt_internalSetInt.ml index acbe70c3b5..325a5c23ad 100644 --- a/jscomp/others/belt_internalSetInt.ml +++ b/jscomp/others/belt_internalSetInt.ml @@ -106,7 +106,7 @@ let rec addMutate t (x : value)= -let ofArray (xs : value array) = +let fromArray (xs : value array) = let len = A.length xs in if len = 0 then N.empty else @@ -114,10 +114,10 @@ let ofArray (xs : value array) = let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next ; - N.ofSortedArrayRevAux xs (!next - 1) !next + N.fromSortedArrayRevAux xs (!next - 1) !next end ) in for i = !next to len - 1 do diff --git a/jscomp/others/belt_internalSetString.ml b/jscomp/others/belt_internalSetString.ml index 570a6412e4..8ea6f725d8 100644 --- a/jscomp/others/belt_internalSetString.ml +++ b/jscomp/others/belt_internalSetString.ml @@ -106,7 +106,7 @@ let rec addMutate t (x : value)= -let ofArray (xs : value array) = +let fromArray (xs : value array) = let len = A.length xs in if len = 0 then N.empty else @@ -114,10 +114,10 @@ let ofArray (xs : value array) = let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next ; - N.ofSortedArrayRevAux xs (!next - 1) !next + N.fromSortedArrayRevAux xs (!next - 1) !next end ) in for i = !next to len - 1 do diff --git a/jscomp/others/internal_map.cppo.ml b/jscomp/others/internal_map.cppo.ml index 39acc2d616..b397ce3c26 100644 --- a/jscomp/others/internal_map.cppo.ml +++ b/jscomp/others/internal_map.cppo.ml @@ -199,7 +199,7 @@ let rec addMutate (t : _ t) x data : _ t = ); N.return (N.balMutate nt) -let ofArray (xs : (key * _) array) = +let fromArray (xs : (key * _) array) = let len = A.length xs in if len = 0 then N.empty else @@ -211,10 +211,10 @@ let ofArray (xs : (key * _) array) = in let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next; - N.ofSortedArrayRevAux xs (!next - 1) (!next) + N.fromSortedArrayRevAux xs (!next - 1) (!next) end ) in for i = !next to len - 1 do diff --git a/jscomp/others/internal_set.cppo.ml b/jscomp/others/internal_set.cppo.ml index ef50779829..08e7b01508 100644 --- a/jscomp/others/internal_set.cppo.ml +++ b/jscomp/others/internal_set.cppo.ml @@ -111,7 +111,7 @@ let rec addMutate t (x : value)= -let ofArray (xs : value array) = +let fromArray (xs : value array) = let len = A.length xs in if len = 0 then N.empty else @@ -119,10 +119,10 @@ let ofArray (xs : value array) = let result = ref ( if !next >= 0 then - N.ofSortedArrayAux xs 0 !next + N.fromSortedArrayAux xs 0 !next else begin next := - !next ; - N.ofSortedArrayRevAux xs (!next - 1) !next + N.fromSortedArrayRevAux xs (!next - 1) !next end ) in for i = !next to len - 1 do diff --git a/jscomp/others/map.cppo.ml b/jscomp/others/map.cppo.ml index 164288812c..c21446bddb 100644 --- a/jscomp/others/map.cppo.ml +++ b/jscomp/others/map.cppo.ml @@ -166,5 +166,5 @@ let getExn = I.getExn let split = I.split let mergeU = I.mergeU let merge = I.merge -let fromArray = I.ofArray -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray diff --git a/jscomp/others/mapm.cppo.ml b/jscomp/others/mapm.cppo.ml index f20573b370..36f6ad250c 100644 --- a/jscomp/others/mapm.cppo.ml +++ b/jscomp/others/mapm.cppo.ml @@ -161,7 +161,7 @@ let removeMany (type key) (type id) (d : _ t) xs = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray diff --git a/jscomp/others/set.cppo.ml b/jscomp/others/set.cppo.ml index 76b3f0dab5..78d2ba9864 100644 --- a/jscomp/others/set.cppo.ml +++ b/jscomp/others/set.cppo.ml @@ -35,7 +35,8 @@ let partitionU = N.partitionSharedU let size = N.size let toList = N.toList let toArray = N.toArray -let ofSortedArrayUnsafe = N.ofSortedArrayUnsafe +let fromSortedArrayUnsafe = N.fromSortedArrayUnsafe +let ofSortedArrayUnsafe = N.fromSortedArrayUnsafe let checkInvariantInternal = N.checkInvariantInternal let rec add (t : t) (x : value) : t = @@ -96,7 +97,8 @@ let removeMany h arr = done ; !v -let ofArray = I.ofArray +let fromArray = I.fromArray +let ofArray = I.fromArray let cmp = I.cmp let eq = I.eq let get = I.get diff --git a/jscomp/others/set.cppo.mli b/jscomp/others/set.cppo.mli index 3dcd1f4e72..d61e5a5cad 100644 --- a/jscomp/others/set.cppo.mli +++ b/jscomp/others/set.cppo.mli @@ -46,7 +46,12 @@ val empty: t val ofArray: value array -> t +[@@ocaml.deprecated "Use fromArray instead"] val ofSortedArrayUnsafe: value array -> t +[@@ocaml.deprecated "Use fromSortedArrayUnsafe instead"] + +val fromArray: value array -> t +val fromSortedArrayUnsafe: value array -> t val isEmpty: t -> bool val has: t -> value -> bool diff --git a/jscomp/others/setm.cppo.ml b/jscomp/others/setm.cppo.ml index 8a7453e488..5cb56923c1 100644 --- a/jscomp/others/setm.cppo.ml +++ b/jscomp/others/setm.cppo.ml @@ -222,7 +222,7 @@ let toArray d = let fromSortedArrayUnsafe xs = - t ~data:(N.ofSortedArrayUnsafe xs) + t ~data:(N.fromSortedArrayUnsafe xs) let ofSortedArrayUnsafe = fromSortedArrayUnsafe @@ -232,7 +232,7 @@ let checkInvariantInternal d = let fromArray xs = - t ~data:(I.ofArray xs) + t ~data:(I.fromArray xs) let ofArray = fromArray @@ -254,17 +254,17 @@ let split d key = if i < 0 then let next = - i -1 in (t - ~data:(N.ofSortedArrayAux arr 0 next) + ~data:(N.fromSortedArrayAux arr 0 next) , t - ~data:(N.ofSortedArrayAux arr next (len - next)) + ~data:(N.fromSortedArrayAux arr next (len - next)) ), false else (t - ~data:(N.ofSortedArrayAux arr 0 i) + ~data:(N.fromSortedArrayAux arr 0 i) , t - ~data:(N.ofSortedArrayAux arr (i+1) (len - i - 1)) + ~data:(N.fromSortedArrayAux arr (i+1) (len - i - 1)) ), true let keepU d p = @@ -300,7 +300,7 @@ let intersect dataa datab = else let tmp2 = A.makeUninitializedUnsafe (min sizea sizeb) in let k = S.intersect tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let diff dataa datab : t = let dataa, datab = data dataa, data datab in @@ -322,7 +322,7 @@ let diff dataa datab : t = else let tmp2 = A.makeUninitializedUnsafe sizea in let k = S.diff tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let union (dataa : t) (datab : t) : t = let dataa, datab = data dataa, data datab in @@ -339,11 +339,11 @@ let union (dataa : t) (datab : t) : t = if (A.getUnsafe tmp (sizea - 1) < A.getUnsafe tmp sizea) then - t ~data:(N.ofSortedArrayAux tmp 0 totalSize) + t ~data:(N.fromSortedArrayAux tmp 0 totalSize) else let tmp2 = A.makeUninitializedUnsafe totalSize in let k = S.union tmp 0 sizea tmp sizea sizeb tmp2 0 in - t ~data:(N.ofSortedArrayAux tmp2 0 k) + t ~data:(N.fromSortedArrayAux tmp2 0 k) let has d x = I.has (data d) x From 5bd0b7f3967cfebfac76d6d96b53014351555879 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 7 Mar 2018 22:17:34 -0800 Subject: [PATCH 3/5] One last ofArray* --- jscomp/others/belt_List.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jscomp/others/belt_List.ml b/jscomp/others/belt_List.ml index eaba577e2c..0b4f6da2d2 100644 --- a/jscomp/others/belt_List.ml +++ b/jscomp/others/belt_List.ml @@ -394,12 +394,12 @@ let rec fillAux arr i x = A.setUnsafe arr i h ; fillAux arr (i + 1) t -let rec ofArrayAux a i res = +let rec fromArrayAux a i res = if i < 0 then res - else ofArrayAux a (i - 1) (A.getUnsafe a i :: res) + else fromArrayAux a (i - 1) (A.getUnsafe a i :: res) let fromArray a = - ofArrayAux a (A.length a - 1) [] + fromArrayAux a (A.length a - 1) [] let ofArray = fromArray @@ -412,7 +412,7 @@ let toArray ( x : _ t) = let shuffle xs = let v = toArray xs in A.shuffleInPlace v ; - ofArray v + fromArray v let rec fillAuxMap arr i x f = match x with From c6980eea93eeea5668ce4769bbd7cdc11680f9d6 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 7 Mar 2018 22:36:24 -0800 Subject: [PATCH 4/5] Update tests --- jscomp/test/bs_map_set_dict_test.ml | 2 +- jscomp/test/bs_map_test.ml | 6 +++--- jscomp/test/bs_mutable_set_test.ml | 30 +++++++++++++-------------- jscomp/test/bs_set_int_test.ml | 32 ++++++++++++++--------------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/jscomp/test/bs_map_set_dict_test.ml b/jscomp/test/bs_map_set_dict_test.ml index 15e1590479..255cc08330 100644 --- a/jscomp/test/bs_map_set_dict_test.ml +++ b/jscomp/test/bs_map_set_dict_test.ml @@ -5,7 +5,7 @@ let b loc v = Mt.bool_suites ~suites ~test_id loc v module Icmp = (val Belt.Id.comparable - ~cmp:(fun (x : int) y -> + (fun (x : int) y -> compare x y ) ) diff --git a/jscomp/test/bs_map_test.ml b/jscomp/test/bs_map_test.ml index 82f97fc6b5..09e12494dd 100644 --- a/jscomp/test/bs_map_test.ml +++ b/jscomp/test/bs_map_test.ml @@ -16,14 +16,14 @@ module N = Belt.Set.Int module A = Belt.Array -let mapOfArray x = M.ofArray x -let setOfArray x = N.ofArray x +let mapOfArray x = M.fromArray x +let setOfArray x = N.fromArray x let emptyMap () = M.empty let () = let v = (A.makeByAndShuffle 1_000_000 (fun i -> (i,i))) in - let u = M.ofArray v in + let u = M.fromArray v in (M.checkInvariantInternal u); let firstHalf = A.slice v 0 2_000 in let xx = A.reduce firstHalf u diff --git a/jscomp/test/bs_mutable_set_test.ml b/jscomp/test/bs_mutable_set_test.ml index 1bfb75e8cb..6337933c7a 100644 --- a/jscomp/test/bs_mutable_set_test.ml +++ b/jscomp/test/bs_mutable_set_test.ml @@ -11,12 +11,12 @@ module A = Belt.Array module L = Belt.List let (++) = A.concat let empty = N.make -let ofArray = N.ofArray +let fromArray = N.fromArray (************************************************) include (struct let () = - let u = ofArray (I.range 0 30) in + let u = fromArray (I.range 0 30) in b __LOC__ (N.removeCheck u 0); b __LOC__ (not (N.removeCheck u 0)); b __LOC__ (N.removeCheck u 30); @@ -59,7 +59,7 @@ let () = let () = - let v = ofArray (I.randomRange 1_000 2_000) in + let v = fromArray (I.randomRange 1_000 2_000) in let bs = A.map (I.randomRange 500 1499) (fun x -> N.removeCheck v x ) in let indeedRemoved = A.reduce bs 0 (fun acc x -> if x then acc + 1 else acc) in eq __LOC__ indeedRemoved 500; @@ -97,7 +97,7 @@ let () = b __LOC__ (N.isEmpty (N.intersect aa bb)) let (++) = N.union -let f = ofArray +let f = fromArray let (=~) = N.eq let () = let aa = f (I.randomRange 0 100) in @@ -154,7 +154,7 @@ let () = ) let () = - let a0 = ofArray (I.randomRange 0 1000) in + let a0 = fromArray (I.randomRange 0 1000) in let a1,a2 = ( N.keep a0 (fun x -> x mod 2 = 0), @@ -189,7 +189,7 @@ let () = let () = let u = I.randomRange 0 100_000 ++ I.randomRange 0 100 in - let v = N.ofArray u in + let v = N.fromArray u in eq __LOC__ (N.size v) 100_001; let u = I.randomRange 50_000 80_000 in @@ -207,7 +207,7 @@ let () = b __LOC__ (N.isEmpty v ) let () = - let v = N.ofArray (A.makeBy 30 (fun i -> i)) in + let v = N.fromArray (A.makeBy 30 (fun i -> i)) in N.remove v 30; N.remove v 29 ; b __LOC__ (Js.eqUndefined 28 (N.maxUndefined v )); @@ -240,7 +240,7 @@ let () = id __LOC__ (I.range 0 1000) let () = - let v = N.ofArray (I.randomRange 0 1000) in + let v = N.fromArray (I.randomRange 0 1000) in let copyV = N.keep v (fun x -> x mod 8 = 0) in let aa,bb = N.partition v (fun x -> x mod 8 = 0) in let cc = N.keep v (fun x -> x mod 8 <> 0) in @@ -254,18 +254,18 @@ let () = b __LOC__ (N.eq cc bb) let () = - let v = N.ofArray (I.randomRange 0 1000) in + let v = N.fromArray (I.randomRange 0 1000) in let ((aa,bb),_) = N.split v 400 in - b __LOC__ (N.eq aa (N.ofArray (I.randomRange 0 399))) ; - b __LOC__ (N.eq bb (N.ofArray (I.randomRange 401 1000))); - let d = N.ofArray (A.map (I.randomRange 0 1000) (fun x -> x * 2)) in + b __LOC__ (N.eq aa (N.fromArray (I.randomRange 0 399))) ; + b __LOC__ (N.eq bb (N.fromArray (I.randomRange 401 1000))); + let d = N.fromArray (A.map (I.randomRange 0 1000) (fun x -> x * 2)) in let ((cc,dd), _) = N.split d 1001 in - b __LOC__ (N.eq cc (N.ofArray (A.makeBy 501 (fun x -> x * 2)))); - b __LOC__ (N.eq dd (N.ofArray (A.makeBy 500 (fun x -> 1002 + x * 2)))) + b __LOC__ (N.eq cc (N.fromArray (A.makeBy 501 (fun x -> x * 2)))); + b __LOC__ (N.eq dd (N.fromArray (A.makeBy 500 (fun x -> 1002 + x * 2)))) let (++) = N.union -let f = N.ofArray +let f = N.fromArray let (=~) = N.eq let () = let aa = f (I.randomRange 0 100) in diff --git a/jscomp/test/bs_set_int_test.ml b/jscomp/test/bs_set_int_test.ml index 552398be83..66a11b49a8 100644 --- a/jscomp/test/bs_set_int_test.ml +++ b/jscomp/test/bs_set_int_test.ml @@ -8,10 +8,10 @@ module N = Belt.Set.Int module I = Array_data_util module A = Belt.Array let (=~) s i = - N.(eq (ofArray i) s) + N.(eq (fromArray i) s) let (=*) a b = - N.(eq (ofArray a) (ofArray b)) -let ofA = N.ofArray + N.(eq (fromArray a) (fromArray b)) +let ofA = N.fromArray let ()= b __LOC__ @@ -98,17 +98,17 @@ let () = let () = let count = 1_000_000 in let v = ((A.makeByAndShuffle count (fun i -> i))) in - let u = N.ofArray v in + let u = N.fromArray v in (N.checkInvariantInternal u ); let firstHalf = A.slice v 0 2_000 in let xx = Belt.Array.reduce firstHalf u N.remove in (N.checkInvariantInternal u); - b __LOC__ N.(eq (union (ofArray firstHalf) xx) u) + b __LOC__ N.(eq (union (fromArray firstHalf) xx) u) let () = - let aa = N.ofArray (I.randomRange 0 100) in - let bb = N.ofArray (I.randomRange 0 200) in - let cc = N.ofArray (I.randomRange 120 200) in + let aa = N.fromArray (I.randomRange 0 100) in + let bb = N.fromArray (I.randomRange 0 200) in + let cc = N.fromArray (I.randomRange 120 200) in let dd = N.union aa cc in b __LOC__ (N.subset aa bb); b __LOC__ (N.subset dd bb); @@ -119,8 +119,8 @@ let () = let () = - let aa = N.ofArray (I.randomRange 0 100) in - let bb = N.ofArray (I.randomRange 0 100) in + let aa = N.fromArray (I.randomRange 0 100) in + let bb = N.fromArray (I.randomRange 0 100) in let cc = N.add bb 101 in let dd = N.remove bb 99 in let ee = N.add dd 101 in @@ -133,9 +133,9 @@ let () = let a0 = N.empty in let a1 = N.mergeMany a0 (I.randomRange 0 100) in let a2 = N.removeMany a1 (I.randomRange 40 100) in - let a3 = N.ofArray (I.randomRange 0 39) in + let a3 = N.fromArray (I.randomRange 0 39) in let (a4,a5), pres = N.split a1 40 in - b __LOC__ (N.eq a1 (N.ofArray (I.randomRange 0 100))); + b __LOC__ (N.eq a1 (N.fromArray (I.randomRange 0 100))); b __LOC__ (N.eq a2 a3); b __LOC__ pres; b __LOC__ (N.eq a3 a4); @@ -158,10 +158,10 @@ let () = b __LOC__ (not pres) let () = - let v = N.ofArray (I.randomRange 0 2_000) in - let v0 = N.ofArray (I.randomRange 0 2_000) in - let v1 = N.ofArray (I.randomRange 1 2_001) in - let v2 = N.ofArray (I.randomRange 3 2_002) in + let v = N.fromArray (I.randomRange 0 2_000) in + let v0 = N.fromArray (I.randomRange 0 2_000) in + let v1 = N.fromArray (I.randomRange 1 2_001) in + let v2 = N.fromArray (I.randomRange 3 2_002) in let v3 = N.removeMany v2 [|2_002; 2_001|] in let us = A.map (I.randomRange 1_000 3_000) (fun x -> N.has v x) in let counted = A.reduce us 0 (fun acc x -> if x then acc + 1 else acc ) in From c489bc55972e027a2c51743dc756244c94f94bfc Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 7 Mar 2018 22:56:14 -0800 Subject: [PATCH 5/5] Check in js artifacts to make tests pass --- jscomp/test/bs_map_test.js | 6 +- jscomp/test/bs_mutable_set_test.js | 134 ++++++++++++++--------------- jscomp/test/bs_set_int_test.js | 68 +++++++-------- lib/js/belt_HashMap.js | 7 +- lib/js/belt_HashMapInt.js | 7 +- lib/js/belt_HashMapString.js | 7 +- lib/js/belt_HashSet.js | 5 +- lib/js/belt_HashSetInt.js | 5 +- lib/js/belt_HashSetString.js | 5 +- lib/js/belt_List.js | 7 +- lib/js/belt_Map.js | 7 +- lib/js/belt_MapDict.js | 5 +- lib/js/belt_MapInt.js | 5 +- lib/js/belt_MapString.js | 5 +- lib/js/belt_MutableMap.js | 9 +- lib/js/belt_MutableMapInt.js | 7 +- lib/js/belt_MutableMapString.js | 7 +- lib/js/belt_MutableQueue.js | 5 +- lib/js/belt_MutableSet.js | 34 +++++--- lib/js/belt_MutableSetInt.js | 30 ++++--- lib/js/belt_MutableSetString.js | 30 ++++--- lib/js/belt_Set.js | 14 ++- lib/js/belt_SetDict.js | 10 ++- lib/js/belt_SetInt.js | 10 ++- lib/js/belt_SetString.js | 10 ++- lib/js/belt_internalAVLset.js | 36 ++++---- lib/js/belt_internalAVLtree.js | 30 +++---- lib/js/belt_internalMapInt.js | 8 +- lib/js/belt_internalMapString.js | 8 +- lib/js/belt_internalSetInt.js | 8 +- lib/js/belt_internalSetString.js | 8 +- 31 files changed, 311 insertions(+), 226 deletions(-) diff --git a/jscomp/test/bs_map_test.js b/jscomp/test/bs_map_test.js index 6b01827c83..22013247ad 100644 --- a/jscomp/test/bs_map_test.js +++ b/jscomp/test/bs_map_test.js @@ -41,9 +41,9 @@ function b(loc, v) { return /* () */0; } -var mapOfArray = Belt_MapInt.ofArray; +var mapOfArray = Belt_MapInt.fromArray; -var setOfArray = Belt_SetInt.ofArray; +var setOfArray = Belt_SetInt.fromArray; function emptyMap() { return Belt_MapInt.empty; @@ -56,7 +56,7 @@ var v = Belt_Array.makeByAndShuffle(1000000, (function (i) { ]; })); -var u = Belt_MapInt.ofArray(v); +var u = Belt_MapInt.fromArray(v); Belt_MapInt.checkInvariantInternal(u); diff --git a/jscomp/test/bs_mutable_set_test.js b/jscomp/test/bs_mutable_set_test.js index d869512c97..78de3fb6e0 100644 --- a/jscomp/test/bs_mutable_set_test.js +++ b/jscomp/test/bs_mutable_set_test.js @@ -26,7 +26,7 @@ function b(loc, x) { var xs = Array_data_util.range(0, 30); var u = { - data: Belt_internalSetInt.ofArray(xs) + data: Belt_internalSetInt.fromArray(xs) }; b("File \"bs_mutable_set_test.ml\", line 20, characters 4-11", Belt_MutableSetInt.removeCheck(u, 0)); @@ -106,7 +106,7 @@ b("File \"bs_mutable_set_test.ml\", line 58, characters 4-11", Belt_internalAVLs var xs$1 = Array_data_util.randomRange(1000, 2000); var v = { - data: Belt_internalSetInt.ofArray(xs$1) + data: Belt_internalSetInt.fromArray(xs$1) }; var bs = Belt_Array.map(Array_data_util.randomRange(500, 1499), (function (x) { @@ -226,13 +226,13 @@ b("File \"bs_mutable_set_test.ml\", line 97, characters 4-11", Belt_internalAVLs var xs$2 = Array_data_util.randomRange(0, 100); var aa$2 = { - data: Belt_internalSetInt.ofArray(xs$2) + data: Belt_internalSetInt.fromArray(xs$2) }; var xs$3 = Array_data_util.randomRange(40, 120); var bb$2 = { - data: Belt_internalSetInt.ofArray(xs$3) + data: Belt_internalSetInt.fromArray(xs$3) }; var cc = Belt_MutableSetInt.union(aa$2, bb$2); @@ -240,7 +240,7 @@ var cc = Belt_MutableSetInt.union(aa$2, bb$2); var xs$4 = Array_data_util.randomRange(0, 120); b("File \"bs_mutable_set_test.ml\", line 106, characters 4-11", Belt_MutableSetInt.eq(cc, { - data: Belt_internalSetInt.ofArray(xs$4) + data: Belt_internalSetInt.fromArray(xs$4) })); var xs$5 = Array_data_util.randomRange(0, 20); @@ -250,11 +250,11 @@ var xs$6 = Array_data_util.randomRange(21, 40); var xs$7 = Array_data_util.randomRange(0, 40); b("File \"bs_mutable_set_test.ml\", line 108, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.ofArray(xs$5) + data: Belt_internalSetInt.fromArray(xs$5) }, { - data: Belt_internalSetInt.ofArray(xs$6) + data: Belt_internalSetInt.fromArray(xs$6) }), { - data: Belt_internalSetInt.ofArray(xs$7) + data: Belt_internalSetInt.fromArray(xs$7) })); var dd = Belt_MutableSetInt.intersect(aa$2, bb$2); @@ -262,7 +262,7 @@ var dd = Belt_MutableSetInt.intersect(aa$2, bb$2); var xs$8 = Array_data_util.randomRange(40, 100); b("File \"bs_mutable_set_test.ml\", line 113, characters 4-11", Belt_MutableSetInt.eq(dd, { - data: Belt_internalSetInt.ofArray(xs$8) + data: Belt_internalSetInt.fromArray(xs$8) })); var xs$9 = Array_data_util.randomRange(0, 20); @@ -270,9 +270,9 @@ var xs$9 = Array_data_util.randomRange(0, 20); var xs$10 = Array_data_util.randomRange(21, 40); b("File \"bs_mutable_set_test.ml\", line 114, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(xs$9) + data: Belt_internalSetInt.fromArray(xs$9) }, { - data: Belt_internalSetInt.ofArray(xs$10) + data: Belt_internalSetInt.fromArray(xs$10) }), { data: Belt_internalAVLset.empty })); @@ -282,15 +282,15 @@ var xs$11 = Array_data_util.randomRange(21, 40); var xs$12 = Array_data_util.randomRange(0, 20); b("File \"bs_mutable_set_test.ml\", line 120, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(xs$11) + data: Belt_internalSetInt.fromArray(xs$11) }, { - data: Belt_internalSetInt.ofArray(xs$12) + data: Belt_internalSetInt.fromArray(xs$12) }), { data: Belt_internalAVLset.empty })); b("File \"bs_mutable_set_test.ml\", line 126, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(/* array */[ + data: Belt_internalSetInt.fromArray(/* array */[ 1, 3, 4, @@ -299,7 +299,7 @@ b("File \"bs_mutable_set_test.ml\", line 126, characters 4-11", Belt_MutableSetI 9 ]) }, { - data: Belt_internalSetInt.ofArray(/* array */[ + data: Belt_internalSetInt.fromArray(/* array */[ 2, 4, 5, @@ -308,7 +308,7 @@ b("File \"bs_mutable_set_test.ml\", line 126, characters 4-11", Belt_MutableSetI 10 ]) }), { - data: Belt_internalSetInt.ofArray(/* int array */[ + data: Belt_internalSetInt.fromArray(/* int array */[ 4, 5 ]) @@ -317,13 +317,13 @@ b("File \"bs_mutable_set_test.ml\", line 126, characters 4-11", Belt_MutableSetI var xs$13 = Array_data_util.randomRange(0, 39); b("File \"bs_mutable_set_test.ml\", line 132, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$2, bb$2), { - data: Belt_internalSetInt.ofArray(xs$13) + data: Belt_internalSetInt.fromArray(xs$13) })); var xs$14 = Array_data_util.randomRange(101, 120); b("File \"bs_mutable_set_test.ml\", line 134, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$2, aa$2), { - data: Belt_internalSetInt.ofArray(xs$14) + data: Belt_internalSetInt.fromArray(xs$14) })); var xs$15 = Array_data_util.randomRange(21, 40); @@ -333,11 +333,11 @@ var xs$16 = Array_data_util.randomRange(0, 20); var xs$17 = Array_data_util.randomRange(21, 40); b("File \"bs_mutable_set_test.ml\", line 136, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$15) + data: Belt_internalSetInt.fromArray(xs$15) }, { - data: Belt_internalSetInt.ofArray(xs$16) + data: Belt_internalSetInt.fromArray(xs$16) }), { - data: Belt_internalSetInt.ofArray(xs$17) + data: Belt_internalSetInt.fromArray(xs$17) })); var xs$18 = Array_data_util.randomRange(0, 20); @@ -347,11 +347,11 @@ var xs$19 = Array_data_util.randomRange(21, 40); var xs$20 = Array_data_util.randomRange(0, 20); b("File \"bs_mutable_set_test.ml\", line 142, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$18) + data: Belt_internalSetInt.fromArray(xs$18) }, { - data: Belt_internalSetInt.ofArray(xs$19) + data: Belt_internalSetInt.fromArray(xs$19) }), { - data: Belt_internalSetInt.ofArray(xs$20) + data: Belt_internalSetInt.fromArray(xs$20) })); var xs$21 = Array_data_util.randomRange(0, 20); @@ -361,17 +361,17 @@ var xs$22 = Array_data_util.randomRange(0, 40); var xs$23 = Array_data_util.randomRange(0, -1); b("File \"bs_mutable_set_test.ml\", line 149, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$21) + data: Belt_internalSetInt.fromArray(xs$21) }, { - data: Belt_internalSetInt.ofArray(xs$22) + data: Belt_internalSetInt.fromArray(xs$22) }), { - data: Belt_internalSetInt.ofArray(xs$23) + data: Belt_internalSetInt.fromArray(xs$23) })); var xs$24 = Array_data_util.randomRange(0, 1000); var a0 = { - data: Belt_internalSetInt.ofArray(xs$24) + data: Belt_internalSetInt.fromArray(xs$24) }; var a1 = Belt_MutableSetInt.keep(a0, (function (x) { @@ -444,7 +444,7 @@ eq("File \"bs_mutable_set_test.ml\", line 188, characters 5-12", Belt_internalAV var u$2 = Belt_Array.concat(Array_data_util.randomRange(0, 100000), Array_data_util.randomRange(0, 100)); var v$3 = { - data: Belt_internalSetInt.ofArray(u$2) + data: Belt_internalSetInt.fromArray(u$2) }; eq("File \"bs_mutable_set_test.ml\", line 193, characters 5-12", Belt_internalAVLset.size(v$3.data), 100001); @@ -472,7 +472,7 @@ var xs$25 = Belt_Array.makeBy(30, (function (i) { })); var v$4 = { - data: Belt_internalSetInt.ofArray(xs$25) + data: Belt_internalSetInt.fromArray(xs$25) }; Belt_MutableSetInt.remove(v$4, 30); @@ -496,9 +496,7 @@ for(var i$5 = 0 ,i_finish$3 = vv$1.length - 1 | 0; i$5 <= i_finish$3; ++i$5){ eq("File \"bs_mutable_set_test.ml\", line 221, characters 5-12", Belt_internalAVLset.size(v$4.data), 0); function id(loc, x) { - var u = { - data: Belt_internalAVLset.ofSortedArrayUnsafe(x) - }; + var u = Belt_MutableSetInt.ofSortedArrayUnsafe(x); Belt_internalAVLset.checkInvariantInternal(u.data); return b(loc, Belt_Array.every2(Belt_internalAVLset.toArray(u.data), x, Caml_obj.caml_equal)); } @@ -589,7 +587,7 @@ id("File \"bs_mutable_set_test.ml\", line 240, characters 5-12", Array_data_util var xs$26 = Array_data_util.randomRange(0, 1000); var v$5 = { - data: Belt_internalSetInt.ofArray(xs$26) + data: Belt_internalSetInt.fromArray(xs$26) }; var copyV = Belt_MutableSetInt.keep(v$5, (function (x) { @@ -623,7 +621,7 @@ b("File \"bs_mutable_set_test.ml\", line 254, characters 4-11", Belt_MutableSetI var xs$27 = Array_data_util.randomRange(0, 1000); var v$6 = { - data: Belt_internalSetInt.ofArray(xs$27) + data: Belt_internalSetInt.fromArray(xs$27) }; var match$6 = Belt_MutableSetInt.split(v$6, 400); @@ -633,13 +631,13 @@ var match$7 = match$6[0]; var xs$28 = Array_data_util.randomRange(0, 399); b("File \"bs_mutable_set_test.ml\", line 259, characters 4-11", Belt_MutableSetInt.eq(match$7[0], { - data: Belt_internalSetInt.ofArray(xs$28) + data: Belt_internalSetInt.fromArray(xs$28) })); var xs$29 = Array_data_util.randomRange(401, 1000); b("File \"bs_mutable_set_test.ml\", line 260, characters 4-11", Belt_MutableSetInt.eq(match$7[1], { - data: Belt_internalSetInt.ofArray(xs$29) + data: Belt_internalSetInt.fromArray(xs$29) })); var xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { @@ -647,7 +645,7 @@ var xs$30 = Belt_Array.map(Array_data_util.randomRange(0, 1000), (function (x) { })); var d$3 = { - data: Belt_internalSetInt.ofArray(xs$30) + data: Belt_internalSetInt.fromArray(xs$30) }; var match$8 = Belt_MutableSetInt.split(d$3, 1001); @@ -659,7 +657,7 @@ var xs$31 = Belt_Array.makeBy(501, (function (x) { })); b("File \"bs_mutable_set_test.ml\", line 263, characters 4-11", Belt_MutableSetInt.eq(match$9[0], { - data: Belt_internalSetInt.ofArray(xs$31) + data: Belt_internalSetInt.fromArray(xs$31) })); var xs$32 = Belt_Array.makeBy(500, (function (x) { @@ -667,19 +665,19 @@ var xs$32 = Belt_Array.makeBy(500, (function (x) { })); b("File \"bs_mutable_set_test.ml\", line 264, characters 4-11", Belt_MutableSetInt.eq(match$9[1], { - data: Belt_internalSetInt.ofArray(xs$32) + data: Belt_internalSetInt.fromArray(xs$32) })); var xs$33 = Array_data_util.randomRange(0, 100); var aa$3 = { - data: Belt_internalSetInt.ofArray(xs$33) + data: Belt_internalSetInt.fromArray(xs$33) }; var xs$34 = Array_data_util.randomRange(40, 120); var bb$3 = { - data: Belt_internalSetInt.ofArray(xs$34) + data: Belt_internalSetInt.fromArray(xs$34) }; var cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); @@ -687,7 +685,7 @@ var cc$2 = Belt_MutableSetInt.union(aa$3, bb$3); var xs$35 = Array_data_util.randomRange(0, 120); b("File \"bs_mutable_set_test.ml\", line 274, characters 4-11", Belt_MutableSetInt.eq(cc$2, { - data: Belt_internalSetInt.ofArray(xs$35) + data: Belt_internalSetInt.fromArray(xs$35) })); var xs$36 = Array_data_util.randomRange(0, 20); @@ -697,11 +695,11 @@ var xs$37 = Array_data_util.randomRange(21, 40); var xs$38 = Array_data_util.randomRange(0, 40); b("File \"bs_mutable_set_test.ml\", line 276, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.union({ - data: Belt_internalSetInt.ofArray(xs$36) + data: Belt_internalSetInt.fromArray(xs$36) }, { - data: Belt_internalSetInt.ofArray(xs$37) + data: Belt_internalSetInt.fromArray(xs$37) }), { - data: Belt_internalSetInt.ofArray(xs$38) + data: Belt_internalSetInt.fromArray(xs$38) })); var dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); @@ -709,7 +707,7 @@ var dd$1 = Belt_MutableSetInt.intersect(aa$3, bb$3); var xs$39 = Array_data_util.randomRange(40, 100); b("File \"bs_mutable_set_test.ml\", line 281, characters 4-11", Belt_MutableSetInt.eq(dd$1, { - data: Belt_internalSetInt.ofArray(xs$39) + data: Belt_internalSetInt.fromArray(xs$39) })); var xs$40 = Array_data_util.randomRange(0, 20); @@ -717,9 +715,9 @@ var xs$40 = Array_data_util.randomRange(0, 20); var xs$41 = Array_data_util.randomRange(21, 40); b("File \"bs_mutable_set_test.ml\", line 282, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(xs$40) + data: Belt_internalSetInt.fromArray(xs$40) }, { - data: Belt_internalSetInt.ofArray(xs$41) + data: Belt_internalSetInt.fromArray(xs$41) }), { data: Belt_internalAVLset.empty })); @@ -729,15 +727,15 @@ var xs$42 = Array_data_util.randomRange(21, 40); var xs$43 = Array_data_util.randomRange(0, 20); b("File \"bs_mutable_set_test.ml\", line 288, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(xs$42) + data: Belt_internalSetInt.fromArray(xs$42) }, { - data: Belt_internalSetInt.ofArray(xs$43) + data: Belt_internalSetInt.fromArray(xs$43) }), { data: Belt_internalAVLset.empty })); b("File \"bs_mutable_set_test.ml\", line 294, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.intersect({ - data: Belt_internalSetInt.ofArray(/* array */[ + data: Belt_internalSetInt.fromArray(/* array */[ 1, 3, 4, @@ -746,7 +744,7 @@ b("File \"bs_mutable_set_test.ml\", line 294, characters 4-11", Belt_MutableSetI 9 ]) }, { - data: Belt_internalSetInt.ofArray(/* array */[ + data: Belt_internalSetInt.fromArray(/* array */[ 2, 4, 5, @@ -755,7 +753,7 @@ b("File \"bs_mutable_set_test.ml\", line 294, characters 4-11", Belt_MutableSetI 10 ]) }), { - data: Belt_internalSetInt.ofArray(/* int array */[ + data: Belt_internalSetInt.fromArray(/* int array */[ 4, 5 ]) @@ -764,13 +762,13 @@ b("File \"bs_mutable_set_test.ml\", line 294, characters 4-11", Belt_MutableSetI var xs$44 = Array_data_util.randomRange(0, 39); b("File \"bs_mutable_set_test.ml\", line 300, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(aa$3, bb$3), { - data: Belt_internalSetInt.ofArray(xs$44) + data: Belt_internalSetInt.fromArray(xs$44) })); var xs$45 = Array_data_util.randomRange(101, 120); b("File \"bs_mutable_set_test.ml\", line 302, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff(bb$3, aa$3), { - data: Belt_internalSetInt.ofArray(xs$45) + data: Belt_internalSetInt.fromArray(xs$45) })); var xs$46 = Array_data_util.randomRange(21, 40); @@ -780,11 +778,11 @@ var xs$47 = Array_data_util.randomRange(0, 20); var xs$48 = Array_data_util.randomRange(21, 40); b("File \"bs_mutable_set_test.ml\", line 304, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$46) + data: Belt_internalSetInt.fromArray(xs$46) }, { - data: Belt_internalSetInt.ofArray(xs$47) + data: Belt_internalSetInt.fromArray(xs$47) }), { - data: Belt_internalSetInt.ofArray(xs$48) + data: Belt_internalSetInt.fromArray(xs$48) })); var xs$49 = Array_data_util.randomRange(0, 20); @@ -794,11 +792,11 @@ var xs$50 = Array_data_util.randomRange(21, 40); var xs$51 = Array_data_util.randomRange(0, 20); b("File \"bs_mutable_set_test.ml\", line 310, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$49) + data: Belt_internalSetInt.fromArray(xs$49) }, { - data: Belt_internalSetInt.ofArray(xs$50) + data: Belt_internalSetInt.fromArray(xs$50) }), { - data: Belt_internalSetInt.ofArray(xs$51) + data: Belt_internalSetInt.fromArray(xs$51) })); var xs$52 = Array_data_util.randomRange(0, 20); @@ -808,11 +806,11 @@ var xs$53 = Array_data_util.randomRange(0, 40); var xs$54 = Array_data_util.randomRange(0, -1); b("File \"bs_mutable_set_test.ml\", line 317, characters 4-11", Belt_MutableSetInt.eq(Belt_MutableSetInt.diff({ - data: Belt_internalSetInt.ofArray(xs$52) + data: Belt_internalSetInt.fromArray(xs$52) }, { - data: Belt_internalSetInt.ofArray(xs$53) + data: Belt_internalSetInt.fromArray(xs$53) }), { - data: Belt_internalSetInt.ofArray(xs$54) + data: Belt_internalSetInt.fromArray(xs$54) })); Mt.from_pair_suites("bs_mutable_set_test.ml", suites[0]); @@ -829,11 +827,11 @@ var L = 0; var empty = Belt_MutableSetInt.make; -var ofArray = Belt_MutableSetInt.ofArray; +var fromArray = Belt_MutableSetInt.fromArray; var $plus$plus = Belt_MutableSetInt.union; -var f = Belt_MutableSetInt.ofArray; +var f = Belt_MutableSetInt.fromArray; var $eq$tilde = Belt_MutableSetInt.eq; @@ -847,7 +845,7 @@ exports.R = R; exports.A = A; exports.L = L; exports.empty = empty; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.$plus$plus = $plus$plus; exports.f = f; exports.$eq$tilde = $eq$tilde; diff --git a/jscomp/test/bs_set_int_test.js b/jscomp/test/bs_set_int_test.js index c4fd42fd51..de71d8036b 100644 --- a/jscomp/test/bs_set_int_test.js +++ b/jscomp/test/bs_set_int_test.js @@ -20,11 +20,11 @@ function b(loc, v) { } function $eq$tilde(s, i) { - return Belt_SetInt.eq(Belt_SetInt.ofArray(i), s); + return Belt_SetInt.eq(Belt_SetInt.fromArray(i), s); } function $eq$star(a, b) { - return Belt_SetInt.eq(Belt_SetInt.ofArray(a), Belt_SetInt.ofArray(b)); + return Belt_SetInt.eq(Belt_SetInt.fromArray(a), Belt_SetInt.fromArray(b)); } b("File \"bs_set_int_test.ml\", line 17, characters 4-11", $eq$star(/* int array */[ @@ -37,17 +37,17 @@ b("File \"bs_set_int_test.ml\", line 17, characters 4-11", $eq$star(/* int array 1 ])); -var u = Belt_SetInt.intersect(Belt_SetInt.ofArray(/* int array */[ +var u = Belt_SetInt.intersect(Belt_SetInt.fromArray(/* int array */[ 1, 2, 3 - ]), Belt_SetInt.ofArray(/* int array */[ + ]), Belt_SetInt.fromArray(/* int array */[ 3, 4, 5 ])); -b("File \"bs_set_int_test.ml\", line 23, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(/* int array */[3]), u)); +b("File \"bs_set_int_test.ml\", line 23, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(/* int array */[3]), u)); function range(i, j) { return $$Array.init((j - i | 0) + 1 | 0, (function (k) { @@ -61,11 +61,11 @@ function revRange(i, j) { }))))); } -var v = Belt_SetInt.ofArray($$Array.append(range(100, 1000), revRange(400, 1500))); +var v = Belt_SetInt.fromArray($$Array.append(range(100, 1000), revRange(400, 1500))); var i = range(100, 1500); -b("File \"bs_set_int_test.ml\", line 36, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(i), v)); +b("File \"bs_set_int_test.ml\", line 36, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i), v)); var match = Belt_SetInt.partition(v, (function (x) { return +(x % 3 === 0); @@ -89,39 +89,39 @@ b("File \"bs_set_int_test.ml\", line 48, characters 4-11", Belt_SetInt.eq(match[ var i$2 = range(50, 100); -var s = Belt_SetInt.intersect(Belt_SetInt.ofArray(range(1, 100)), Belt_SetInt.ofArray(range(50, 200))); +var s = Belt_SetInt.intersect(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); -b("File \"bs_set_int_test.ml\", line 51, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(i$2), s)); +b("File \"bs_set_int_test.ml\", line 51, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i$2), s)); var i$3 = range(1, 200); -var s$1 = Belt_SetInt.union(Belt_SetInt.ofArray(range(1, 100)), Belt_SetInt.ofArray(range(50, 200))); +var s$1 = Belt_SetInt.union(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); -b("File \"bs_set_int_test.ml\", line 54, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(i$3), s$1)); +b("File \"bs_set_int_test.ml\", line 54, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i$3), s$1)); var i$4 = range(1, 49); -var s$2 = Belt_SetInt.diff(Belt_SetInt.ofArray(range(1, 100)), Belt_SetInt.ofArray(range(50, 200))); +var s$2 = Belt_SetInt.diff(Belt_SetInt.fromArray(range(1, 100)), Belt_SetInt.fromArray(range(50, 200))); -b("File \"bs_set_int_test.ml\", line 57, characters 6-13", Belt_SetInt.eq(Belt_SetInt.ofArray(i$4), s$2)); +b("File \"bs_set_int_test.ml\", line 57, characters 6-13", Belt_SetInt.eq(Belt_SetInt.fromArray(i$4), s$2)); var i$5 = revRange(50, 100); -var s$3 = Belt_SetInt.intersect(Belt_SetInt.ofArray(revRange(1, 100)), Belt_SetInt.ofArray(revRange(50, 200))); +var s$3 = Belt_SetInt.intersect(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); -b("File \"bs_set_int_test.ml\", line 60, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(i$5), s$3)); +b("File \"bs_set_int_test.ml\", line 60, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i$5), s$3)); var i$6 = revRange(1, 200); -var s$4 = Belt_SetInt.union(Belt_SetInt.ofArray(revRange(1, 100)), Belt_SetInt.ofArray(revRange(50, 200))); +var s$4 = Belt_SetInt.union(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); -b("File \"bs_set_int_test.ml\", line 63, characters 4-11", Belt_SetInt.eq(Belt_SetInt.ofArray(i$6), s$4)); +b("File \"bs_set_int_test.ml\", line 63, characters 4-11", Belt_SetInt.eq(Belt_SetInt.fromArray(i$6), s$4)); var i$7 = revRange(1, 49); -var s$5 = Belt_SetInt.diff(Belt_SetInt.ofArray(revRange(1, 100)), Belt_SetInt.ofArray(revRange(50, 200))); +var s$5 = Belt_SetInt.diff(Belt_SetInt.fromArray(revRange(1, 100)), Belt_SetInt.fromArray(revRange(50, 200))); -b("File \"bs_set_int_test.ml\", line 66, characters 6-13", Belt_SetInt.eq(Belt_SetInt.ofArray(i$7), s$5)); +b("File \"bs_set_int_test.ml\", line 66, characters 6-13", Belt_SetInt.eq(Belt_SetInt.fromArray(i$7), s$5)); var ss = /* array */[ 1, @@ -134,7 +134,7 @@ var ss = /* array */[ -1 ]; -var v$1 = Belt_SetInt.ofArray(/* array */[ +var v$1 = Belt_SetInt.fromArray(/* array */[ 1, 222, 3, @@ -211,7 +211,7 @@ var v$11 = Belt_Array.makeByAndShuffle(1000000, (function (i) { return i; })); -var u$1 = Belt_SetInt.ofArray(v$11); +var u$1 = Belt_SetInt.fromArray(v$11); Belt_SetInt.checkInvariantInternal(u$1); @@ -221,13 +221,13 @@ var xx = Belt_Array.reduce(firstHalf, u$1, Belt_SetInt.remove); Belt_SetInt.checkInvariantInternal(u$1); -b("File \"bs_set_int_test.ml\", line 106, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.ofArray(firstHalf), xx), u$1)); +b("File \"bs_set_int_test.ml\", line 106, characters 4-11", Belt_SetInt.eq(Belt_SetInt.union(Belt_SetInt.fromArray(firstHalf), xx), u$1)); -var aa = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 100)); +var aa = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); -var bb = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 200)); +var bb = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 200)); -var cc = Belt_SetInt.ofArray(Array_data_util.randomRange(120, 200)); +var cc = Belt_SetInt.fromArray(Array_data_util.randomRange(120, 200)); var dd = Belt_SetInt.union(aa, cc); @@ -243,9 +243,9 @@ b("File \"bs_set_int_test.ml\", line 117, characters 4-11", +(Belt_SetInt.add(dd b("File \"bs_set_int_test.ml\", line 118, characters 4-11", 1 - Belt_SetInt.subset(Belt_SetInt.add(dd, 201), bb)); -var aa$1 = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 100)); +var aa$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); -var bb$1 = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 100)); +var bb$1 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)); var cc$1 = Belt_SetInt.add(bb$1, 101); @@ -265,7 +265,7 @@ var a1 = Belt_SetInt.mergeMany(Belt_SetInt.empty, Array_data_util.randomRange(0, var a2 = Belt_SetInt.removeMany(a1, Array_data_util.randomRange(40, 100)); -var a3 = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 39)); +var a3 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 39)); var match$1 = Belt_SetInt.split(a1, 40); @@ -275,7 +275,7 @@ var a5 = match$2[1]; var a4 = match$2[0]; -b("File \"bs_set_int_test.ml\", line 138, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.ofArray(Array_data_util.randomRange(0, 100)))); +b("File \"bs_set_int_test.ml\", line 138, characters 4-11", Belt_SetInt.eq(a1, Belt_SetInt.fromArray(Array_data_util.randomRange(0, 100)))); b("File \"bs_set_int_test.ml\", line 139, characters 4-11", Belt_SetInt.eq(a2, a3)); @@ -319,13 +319,13 @@ b("File \"bs_set_int_test.ml\", line 157, characters 4-11", Belt_SetInt.isEmpty( b("File \"bs_set_int_test.ml\", line 158, characters 4-11", 1 - match$5[1]); -var v$12 = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 2000)); +var v$12 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); -var v0 = Belt_SetInt.ofArray(Array_data_util.randomRange(0, 2000)); +var v0 = Belt_SetInt.fromArray(Array_data_util.randomRange(0, 2000)); -var v1 = Belt_SetInt.ofArray(Array_data_util.randomRange(1, 2001)); +var v1 = Belt_SetInt.fromArray(Array_data_util.randomRange(1, 2001)); -var v2 = Belt_SetInt.ofArray(Array_data_util.randomRange(3, 2002)); +var v2 = Belt_SetInt.fromArray(Array_data_util.randomRange(3, 2002)); var v3 = Belt_SetInt.removeMany(v2, /* int array */[ 2002, @@ -370,7 +370,7 @@ var I = 0; var A = 0; -var ofA = Belt_SetInt.ofArray; +var ofA = Belt_SetInt.fromArray; exports.suites = suites; exports.test_id = test_id; diff --git a/lib/js/belt_HashMap.js b/lib/js/belt_HashMap.js index 439e5eb6a9..a654d5d72f 100644 --- a/lib/js/belt_HashMap.js +++ b/lib/js/belt_HashMap.js @@ -226,7 +226,7 @@ function make(hintSize, id) { return Belt_internalBucketsType.make(id[/* hash */0], id[/* eq */1], hintSize); } -function ofArray(arr, id) { +function fromArray(arr, id) { var hash = id[/* hash */0]; var eq = id[/* eq */1]; var len = arr.length; @@ -281,6 +281,8 @@ var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; var logStats = Belt_internalBuckets.logStats; +var ofArray = fromArray; + exports.Int = Int; exports.$$String = $$String; exports.make = make; @@ -301,8 +303,9 @@ exports.size = size; exports.toArray = toArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; exports.logStats = logStats; +exports.ofArray = ofArray; /* No side effect */ diff --git a/lib/js/belt_HashMapInt.js b/lib/js/belt_HashMapInt.js index 9e485ce2c1..ffc502442a 100644 --- a/lib/js/belt_HashMapInt.js +++ b/lib/js/belt_HashMapInt.js @@ -218,7 +218,7 @@ function size(prim) { return prim.size; } -function ofArray(arr) { +function fromArray(arr) { var len = arr.length; var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ @@ -265,6 +265,8 @@ var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; var logStats = Belt_internalBuckets.logStats; +var ofArray = fromArray; + exports.make = make; exports.clear = clear; exports.isEmpty = isEmpty; @@ -283,8 +285,9 @@ exports.size = size; exports.toArray = toArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; exports.logStats = logStats; +exports.ofArray = ofArray; /* No side effect */ diff --git a/lib/js/belt_HashMapString.js b/lib/js/belt_HashMapString.js index 556f78edd0..778fbc2c18 100644 --- a/lib/js/belt_HashMapString.js +++ b/lib/js/belt_HashMapString.js @@ -218,7 +218,7 @@ function size(prim) { return prim.size; } -function ofArray(arr) { +function fromArray(arr) { var len = arr.length; var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ @@ -265,6 +265,8 @@ var getBucketHistogram = Belt_internalBuckets.getBucketHistogram; var logStats = Belt_internalBuckets.logStats; +var ofArray = fromArray; + exports.make = make; exports.clear = clear; exports.isEmpty = isEmpty; @@ -283,8 +285,9 @@ exports.size = size; exports.toArray = toArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; exports.logStats = logStats; +exports.ofArray = ofArray; /* No side effect */ diff --git a/lib/js/belt_HashSet.js b/lib/js/belt_HashSet.js index e9e4281bc8..4cf9439567 100644 --- a/lib/js/belt_HashSet.js +++ b/lib/js/belt_HashSet.js @@ -173,7 +173,7 @@ function size(prim) { return prim.size; } -function ofArray(arr, id) { +function fromArray(arr, id) { var eq = id[/* eq */1]; var hash = id[/* hash */0]; var len = arr.length; @@ -216,6 +216,8 @@ var logStats = Belt_internalSetBuckets.logStats; var toArray = Belt_internalSetBuckets.toArray; +var ofArray = fromArray; + var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; exports.Int = Int; @@ -235,6 +237,7 @@ exports.size = size; exports.logStats = logStats; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; /* No side effect */ diff --git a/lib/js/belt_HashSetInt.js b/lib/js/belt_HashSetInt.js index 0cd7089dce..eded1d178a 100644 --- a/lib/js/belt_HashSetInt.js +++ b/lib/js/belt_HashSetInt.js @@ -166,7 +166,7 @@ function size(prim) { return prim.size; } -function ofArray(arr) { +function fromArray(arr) { var len = arr.length; var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ @@ -201,6 +201,8 @@ var logStats = Belt_internalSetBuckets.logStats; var toArray = Belt_internalSetBuckets.toArray; +var ofArray = fromArray; + var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; exports.make = make; @@ -218,6 +220,7 @@ exports.size = size; exports.logStats = logStats; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; /* No side effect */ diff --git a/lib/js/belt_HashSetString.js b/lib/js/belt_HashSetString.js index 8483e541cb..d5005e5483 100644 --- a/lib/js/belt_HashSetString.js +++ b/lib/js/belt_HashSetString.js @@ -166,7 +166,7 @@ function size(prim) { return prim.size; } -function ofArray(arr) { +function fromArray(arr) { var len = arr.length; var v = Belt_internalBucketsType.make(/* () */0, /* () */0, len); for(var i = 0 ,i_finish = len - 1 | 0; i <= i_finish; ++i){ @@ -201,6 +201,8 @@ var logStats = Belt_internalSetBuckets.logStats; var toArray = Belt_internalSetBuckets.toArray; +var ofArray = fromArray; + var getBucketHistogram = Belt_internalSetBuckets.getBucketHistogram; exports.make = make; @@ -218,6 +220,7 @@ exports.size = size; exports.logStats = logStats; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.mergeMany = mergeMany; exports.getBucketHistogram = getBucketHistogram; /* No side effect */ diff --git a/lib/js/belt_List.js b/lib/js/belt_List.js index 3944f140ad..23541896a0 100644 --- a/lib/js/belt_List.js +++ b/lib/js/belt_List.js @@ -654,7 +654,7 @@ function fillAux(arr, _i, _x) { }; } -function ofArray(a) { +function fromArray(a) { var a$1 = a; var _i = a.length - 1 | 0; var _res = /* [] */0; @@ -685,7 +685,7 @@ function toArray(x) { function shuffle(xs) { var v = toArray(xs); Belt_Array.shuffleInPlace(v); - return ofArray(v); + return fromArray(v); } function reverseConcat(_l1, _l2) { @@ -1447,6 +1447,8 @@ function zip(l1, l2) { var size = length; +var ofArray = fromArray; + exports.length = length; exports.size = size; exports.head = head; @@ -1475,6 +1477,7 @@ exports.zipBy = zipBy; exports.mapWithIndexU = mapWithIndexU; exports.mapWithIndex = mapWithIndex; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.toArray = toArray; exports.reverse = reverse; exports.mapReverseU = mapReverseU; diff --git a/lib/js/belt_Map.js b/lib/js/belt_Map.js index c1bd5af8d2..5e80a50e73 100644 --- a/lib/js/belt_Map.js +++ b/lib/js/belt_Map.js @@ -3,11 +3,11 @@ var Curry = require("./curry.js"); var Belt_MapDict = require("./belt_MapDict.js"); -function ofArray(data, id) { +function fromArray(data, id) { var cmp = id[/* cmp */0]; return { cmp: cmp, - data: Belt_MapDict.ofArray(data, cmp) + data: Belt_MapDict.fromArray(data, cmp) }; } @@ -303,6 +303,8 @@ var $$String = 0; var Dict = 0; +var ofArray = fromArray; + exports.Int = Int; exports.$$String = $$String; exports.Dict = Dict; @@ -325,6 +327,7 @@ exports.size = size; exports.toArray = toArray; exports.toList = toList; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MapDict.js b/lib/js/belt_MapDict.js index ac4cd79059..4b244b0f50 100644 --- a/lib/js/belt_MapDict.js +++ b/lib/js/belt_MapDict.js @@ -312,7 +312,9 @@ var toList = Belt_internalAVLtree.toList; var toArray = Belt_internalAVLtree.toArray; -var ofArray = Belt_internalAVLtree.ofArray; +var ofArray = Belt_internalAVLtree.fromArray; + +var fromArray = Belt_internalAVLtree.fromArray; var keysToArray = Belt_internalAVLtree.keysToArray; @@ -379,6 +381,7 @@ exports.size = size; exports.toList = toList; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MapInt.js b/lib/js/belt_MapInt.js index 662e79e2b9..e62c6d40d6 100644 --- a/lib/js/belt_MapInt.js +++ b/lib/js/belt_MapInt.js @@ -199,7 +199,9 @@ var toList = Belt_internalAVLtree.toList; var toArray = Belt_internalAVLtree.toArray; -var ofArray = Belt_internalMapInt.ofArray; +var ofArray = Belt_internalMapInt.fromArray; + +var fromArray = Belt_internalMapInt.fromArray; var keysToArray = Belt_internalAVLtree.keysToArray; @@ -272,6 +274,7 @@ exports.size = size; exports.toList = toList; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MapString.js b/lib/js/belt_MapString.js index e9294180cb..e19cc244fa 100644 --- a/lib/js/belt_MapString.js +++ b/lib/js/belt_MapString.js @@ -199,7 +199,9 @@ var toList = Belt_internalAVLtree.toList; var toArray = Belt_internalAVLtree.toArray; -var ofArray = Belt_internalMapString.ofArray; +var ofArray = Belt_internalMapString.fromArray; + +var fromArray = Belt_internalMapString.fromArray; var keysToArray = Belt_internalAVLtree.keysToArray; @@ -272,6 +274,7 @@ exports.size = size; exports.toList = toList; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MutableMap.js b/lib/js/belt_MutableMap.js index 01a94829af..1d253b654b 100644 --- a/lib/js/belt_MutableMap.js +++ b/lib/js/belt_MutableMap.js @@ -315,11 +315,11 @@ function has(m, x) { return Belt_internalAVLtree.has(m.data, x, m.cmp); } -function ofArray(data, id) { +function fromArray(data, id) { var cmp = id[/* cmp */0]; return { cmp: cmp, - data: Belt_internalAVLtree.ofArray(data, cmp) + data: Belt_internalAVLtree.fromArray(data, cmp) }; } @@ -358,6 +358,8 @@ var Int = 0; var $$String = 0; +var ofArray = fromArray; + exports.Int = Int; exports.$$String = $$String; exports.make = make; @@ -379,7 +381,7 @@ exports.some = some; exports.size = size; exports.toList = toList; exports.toArray = toArray; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; @@ -395,6 +397,7 @@ exports.getUndefined = getUndefined; exports.getWithDefault = getWithDefault; exports.getExn = getExn; exports.checkInvariantInternal = checkInvariantInternal; +exports.ofArray = ofArray; exports.remove = remove; exports.removeMany = removeMany; exports.set = set; diff --git a/lib/js/belt_MutableMapInt.js b/lib/js/belt_MutableMapInt.js index 07cb228cd9..f03a3eb7fe 100644 --- a/lib/js/belt_MutableMapInt.js +++ b/lib/js/belt_MutableMapInt.js @@ -286,9 +286,9 @@ function removeMany(d, xs) { } } -function ofArray(xs) { +function fromArray(xs) { return { - data: Belt_internalMapInt.ofArray(xs) + data: Belt_internalMapInt.fromArray(xs) }; } @@ -324,6 +324,8 @@ function getExn(d, x) { return Belt_internalMapInt.getExn(d.data, x); } +var ofArray = fromArray; + exports.make = make; exports.clear = clear; exports.isEmpty = isEmpty; @@ -344,6 +346,7 @@ exports.size = size; exports.toList = toList; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MutableMapString.js b/lib/js/belt_MutableMapString.js index e0bd409b20..54d0ada188 100644 --- a/lib/js/belt_MutableMapString.js +++ b/lib/js/belt_MutableMapString.js @@ -286,9 +286,9 @@ function removeMany(d, xs) { } } -function ofArray(xs) { +function fromArray(xs) { return { - data: Belt_internalMapString.ofArray(xs) + data: Belt_internalMapString.fromArray(xs) }; } @@ -324,6 +324,8 @@ function getExn(d, x) { return Belt_internalMapString.getExn(d.data, x); } +var ofArray = fromArray; + exports.make = make; exports.clear = clear; exports.isEmpty = isEmpty; @@ -344,6 +346,7 @@ exports.size = size; exports.toList = toList; exports.toArray = toArray; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; exports.minKey = minKey; diff --git a/lib/js/belt_MutableQueue.js b/lib/js/belt_MutableQueue.js index fabdc354d6..8d0bb90b09 100644 --- a/lib/js/belt_MutableQueue.js +++ b/lib/js/belt_MutableQueue.js @@ -279,7 +279,7 @@ function toArray(x) { return v; } -function ofArray(arr) { +function fromArray(arr) { var q = make(/* () */0); for(var i = 0 ,i_finish = arr.length - 1 | 0; i <= i_finish; ++i){ add(q, arr[i]); @@ -287,10 +287,13 @@ function ofArray(arr) { return q; } +var ofArray = fromArray; + exports.make = make; exports.clear = clear; exports.isEmpty = isEmpty; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.add = add; exports.peek = peek; exports.peekUndefined = peekUndefined; diff --git a/lib/js/belt_MutableSet.js b/lib/js/belt_MutableSet.js index 431a5a33bf..8148a8eb50 100644 --- a/lib/js/belt_MutableSet.js +++ b/lib/js/belt_MutableSet.js @@ -264,10 +264,10 @@ function toArray(d) { return Belt_internalAVLset.toArray(d.data); } -function ofSortedArrayUnsafe(xs, id) { +function fromSortedArrayUnsafe(xs, id) { return { cmp: id[/* cmp */0], - data: Belt_internalAVLset.ofSortedArrayUnsafe(xs) + data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) }; } @@ -275,11 +275,11 @@ function checkInvariantInternal(d) { return Belt_internalAVLset.checkInvariantInternal(d.data); } -function ofArray(data, id) { +function fromArray(data, id) { var cmp = id[/* cmp */0]; return { cmp: cmp, - data: Belt_internalAVLset.ofArray(data, cmp) + data: Belt_internalAVLset.fromArray(data, cmp) }; } @@ -314,11 +314,11 @@ function split(d, key) { /* tuple */[ { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, next) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) }, { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(arr, next, len - next | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) } ], /* false */0 @@ -328,11 +328,11 @@ function split(d, key) { /* tuple */[ { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, i) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) }, { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) } ], /* true */1 @@ -396,7 +396,7 @@ function intersect(a, b) { var k = Belt_SortArray.intersectU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); return { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -435,7 +435,7 @@ function diff(a, b) { var k = Belt_SortArray.diffU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); return { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -467,14 +467,14 @@ function union(a, b) { if (cmp(tmp[sizea - 1 | 0], tmp[sizea]) < 0) { return { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(tmp, 0, totalSize) + data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) }; } else { var tmp2 = new Array(totalSize); var k = Belt_SortArray.unionU(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0, cmp); return { cmp: cmp, - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -506,11 +506,15 @@ var Int = 0; var $$String = 0; +var ofArray = fromArray; + +var ofSortedArrayUnsafe = fromSortedArrayUnsafe; + exports.Int = Int; exports.$$String = $$String; exports.make = make; -exports.ofArray = ofArray; -exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.copy = copy; exports.isEmpty = isEmpty; exports.has = has; @@ -550,4 +554,6 @@ exports.getUndefined = getUndefined; exports.getExn = getExn; exports.split = split; exports.checkInvariantInternal = checkInvariantInternal; +exports.ofArray = ofArray; +exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; /* No side effect */ diff --git a/lib/js/belt_MutableSetInt.js b/lib/js/belt_MutableSetInt.js index cc545ad52c..eb7dae4d2b 100644 --- a/lib/js/belt_MutableSetInt.js +++ b/lib/js/belt_MutableSetInt.js @@ -261,9 +261,9 @@ function toArray(d) { return Belt_internalAVLset.toArray(d.data); } -function ofSortedArrayUnsafe(xs) { +function fromSortedArrayUnsafe(xs) { return { - data: Belt_internalAVLset.ofSortedArrayUnsafe(xs) + data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) }; } @@ -271,9 +271,9 @@ function checkInvariantInternal(d) { return Belt_internalAVLset.checkInvariantInternal(d.data); } -function ofArray(xs) { +function fromArray(xs) { return { - data: Belt_internalSetInt.ofArray(xs) + data: Belt_internalSetInt.fromArray(xs) }; } @@ -306,10 +306,10 @@ function split(d, key) { return /* tuple */[ /* tuple */[ { - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, next) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) }, { - data: Belt_internalAVLset.ofSortedArrayAux(arr, next, len - next | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) } ], /* false */0 @@ -318,10 +318,10 @@ function split(d, key) { return /* tuple */[ /* tuple */[ { - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, i) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) }, { - data: Belt_internalAVLset.ofSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) } ], /* true */1 @@ -378,7 +378,7 @@ function intersect(dataa, datab) { var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); var k = Belt_SortArrayInt.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -412,7 +412,7 @@ function diff(dataa, datab) { var tmp2 = new Array(sizea); var k = Belt_SortArrayInt.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -440,13 +440,13 @@ function union(dataa, datab) { Belt_internalAVLset.fillArray(datab$1, sizea, tmp); if (tmp[sizea - 1 | 0] < tmp[sizea]) { return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp, 0, totalSize) + data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) }; } else { var tmp2 = new Array(totalSize); var k = Belt_SortArrayInt.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -471,7 +471,13 @@ function copy(d) { }; } +var ofArray = fromArray; + +var ofSortedArrayUnsafe = fromSortedArrayUnsafe; + exports.make = make; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.ofArray = ofArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; exports.copy = copy; diff --git a/lib/js/belt_MutableSetString.js b/lib/js/belt_MutableSetString.js index 5ca4fec0c4..418dedd8ac 100644 --- a/lib/js/belt_MutableSetString.js +++ b/lib/js/belt_MutableSetString.js @@ -261,9 +261,9 @@ function toArray(d) { return Belt_internalAVLset.toArray(d.data); } -function ofSortedArrayUnsafe(xs) { +function fromSortedArrayUnsafe(xs) { return { - data: Belt_internalAVLset.ofSortedArrayUnsafe(xs) + data: Belt_internalAVLset.fromSortedArrayUnsafe(xs) }; } @@ -271,9 +271,9 @@ function checkInvariantInternal(d) { return Belt_internalAVLset.checkInvariantInternal(d.data); } -function ofArray(xs) { +function fromArray(xs) { return { - data: Belt_internalSetString.ofArray(xs) + data: Belt_internalSetString.fromArray(xs) }; } @@ -306,10 +306,10 @@ function split(d, key) { return /* tuple */[ /* tuple */[ { - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, next) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, next) }, { - data: Belt_internalAVLset.ofSortedArrayAux(arr, next, len - next | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, next, len - next | 0) } ], /* false */0 @@ -318,10 +318,10 @@ function split(d, key) { return /* tuple */[ /* tuple */[ { - data: Belt_internalAVLset.ofSortedArrayAux(arr, 0, i) + data: Belt_internalAVLset.fromSortedArrayAux(arr, 0, i) }, { - data: Belt_internalAVLset.ofSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) + data: Belt_internalAVLset.fromSortedArrayAux(arr, i + 1 | 0, (len - i | 0) - 1 | 0) } ], /* true */1 @@ -378,7 +378,7 @@ function intersect(dataa, datab) { var tmp2 = new Array(sizea < sizeb ? sizea : sizeb); var k = Belt_SortArrayString.intersect(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -412,7 +412,7 @@ function diff(dataa, datab) { var tmp2 = new Array(sizea); var k = Belt_SortArrayString.diff(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -440,13 +440,13 @@ function union(dataa, datab) { Belt_internalAVLset.fillArray(datab$1, sizea, tmp); if (tmp[sizea - 1 | 0] < tmp[sizea]) { return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp, 0, totalSize) + data: Belt_internalAVLset.fromSortedArrayAux(tmp, 0, totalSize) }; } else { var tmp2 = new Array(totalSize); var k = Belt_SortArrayString.union(tmp, 0, sizea, tmp, sizea, sizeb, tmp2, 0); return { - data: Belt_internalAVLset.ofSortedArrayAux(tmp2, 0, k) + data: Belt_internalAVLset.fromSortedArrayAux(tmp2, 0, k) }; } } else { @@ -471,7 +471,13 @@ function copy(d) { }; } +var ofArray = fromArray; + +var ofSortedArrayUnsafe = fromSortedArrayUnsafe; + exports.make = make; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.ofArray = ofArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; exports.copy = copy; diff --git a/lib/js/belt_Set.js b/lib/js/belt_Set.js index 8722212e6f..15b40d666b 100644 --- a/lib/js/belt_Set.js +++ b/lib/js/belt_Set.js @@ -3,11 +3,11 @@ var Curry = require("./curry.js"); var Belt_SetDict = require("./belt_SetDict.js"); -function ofArray(data, id) { +function fromArray(data, id) { var cmp = id[/* cmp */0]; return { cmp: cmp, - data: Belt_SetDict.ofArray(data, cmp) + data: Belt_SetDict.fromArray(data, cmp) }; } @@ -229,10 +229,10 @@ function has(m, e) { return Belt_SetDict.has(m.data, e, m.cmp); } -function ofSortedArrayUnsafe(xs, id) { +function fromSortedArrayUnsafe(xs, id) { return { cmp: id[/* cmp */0], - data: Belt_SetDict.ofSortedArrayUnsafe(xs) + data: Belt_SetDict.fromSortedArrayUnsafe(xs) }; } @@ -262,12 +262,18 @@ var $$String = 0; var Dict = 0; +var ofArray = fromArray; + +var ofSortedArrayUnsafe = fromSortedArrayUnsafe; + exports.Int = Int; exports.$$String = $$String; exports.Dict = Dict; exports.make = make; exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.isEmpty = isEmpty; exports.has = has; exports.add = add; diff --git a/lib/js/belt_SetDict.js b/lib/js/belt_SetDict.js index 3997c0a5da..903f875fdf 100644 --- a/lib/js/belt_SetDict.js +++ b/lib/js/belt_SetDict.js @@ -264,9 +264,13 @@ function diff(s1, s2, cmp) { var empty = Belt_internalAVLset.empty; -var ofArray = Belt_internalAVLset.ofArray; +var ofArray = Belt_internalAVLset.fromArray; -var ofSortedArrayUnsafe = Belt_internalAVLset.ofSortedArrayUnsafe; +var ofSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; + +var fromArray = Belt_internalAVLset.fromArray; + +var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; var isEmpty = Belt_internalAVLset.isEmpty; @@ -327,6 +331,8 @@ var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; exports.empty = empty; exports.ofArray = ofArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.isEmpty = isEmpty; exports.has = has; exports.add = add; diff --git a/lib/js/belt_SetInt.js b/lib/js/belt_SetInt.js index 623256e1e8..0af4ed06cc 100644 --- a/lib/js/belt_SetInt.js +++ b/lib/js/belt_SetInt.js @@ -261,9 +261,13 @@ function diff(s1, s2) { var empty = Belt_internalAVLset.empty; -var ofArray = Belt_internalSetInt.ofArray; +var ofArray = Belt_internalSetInt.fromArray; -var ofSortedArrayUnsafe = Belt_internalAVLset.ofSortedArrayUnsafe; +var ofSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; + +var fromArray = Belt_internalSetInt.fromArray; + +var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; var isEmpty = Belt_internalAVLset.isEmpty; @@ -324,6 +328,8 @@ var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; exports.empty = empty; exports.ofArray = ofArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.isEmpty = isEmpty; exports.has = has; exports.add = add; diff --git a/lib/js/belt_SetString.js b/lib/js/belt_SetString.js index f0b2fe2829..5d54ccfb46 100644 --- a/lib/js/belt_SetString.js +++ b/lib/js/belt_SetString.js @@ -261,9 +261,13 @@ function diff(s1, s2) { var empty = Belt_internalAVLset.empty; -var ofArray = Belt_internalSetString.ofArray; +var ofArray = Belt_internalSetString.fromArray; -var ofSortedArrayUnsafe = Belt_internalAVLset.ofSortedArrayUnsafe; +var ofSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; + +var fromArray = Belt_internalSetString.fromArray; + +var fromSortedArrayUnsafe = Belt_internalAVLset.fromSortedArrayUnsafe; var isEmpty = Belt_internalAVLset.isEmpty; @@ -324,6 +328,8 @@ var checkInvariantInternal = Belt_internalAVLset.checkInvariantInternal; exports.empty = empty; exports.ofArray = ofArray; exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromArray = fromArray; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.isEmpty = isEmpty; exports.has = has; exports.add = add; diff --git a/lib/js/belt_internalAVLset.js b/lib/js/belt_internalAVLset.js index ce1e4ea353..8e58a657de 100644 --- a/lib/js/belt_internalAVLset.js +++ b/lib/js/belt_internalAVLset.js @@ -503,12 +503,12 @@ function toArray(n) { } } -function ofSortedArrayRevAux(arr, off, len) { +function fromSortedArrayRevAux(arr, off, len) { if (len > 3 || len < 0) { var nl = len / 2 | 0; - var left = ofSortedArrayRevAux(arr, off, nl); + var left = fromSortedArrayRevAux(arr, off, nl); var mid = arr[off - nl | 0]; - var right = ofSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); + var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); return create(left, mid, right); } else { switch (len) { @@ -540,12 +540,12 @@ function ofSortedArrayRevAux(arr, off, len) { } } -function ofSortedArrayAux(arr, off, len) { +function fromSortedArrayAux(arr, off, len) { if (len > 3 || len < 0) { var nl = len / 2 | 0; - var left = ofSortedArrayAux(arr, off, nl); + var left = fromSortedArrayAux(arr, off, nl); var mid = arr[off + nl | 0]; - var right = ofSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); + var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); return create(left, mid, right); } else { switch (len) { @@ -577,8 +577,8 @@ function ofSortedArrayAux(arr, off, len) { } } -function ofSortedArrayUnsafe(arr) { - return ofSortedArrayAux(arr, 0, arr.length); +function fromSortedArrayUnsafe(arr) { + return fromSortedArrayAux(arr, 0, arr.length); } function keepSharedU(n, p) { @@ -612,7 +612,7 @@ function keepCopyU(n, p) { var size = lengthNode(n); var v = new Array(size); var last = fillArrayWithFilter(n, 0, v, p); - return ofSortedArrayAux(v, 0, last); + return fromSortedArrayAux(v, 0, last); } else { return null; } @@ -634,8 +634,8 @@ function partitionCopyU(n, p) { fillArrayWithPartition(n, cursor, v, p); var forwardLen = cursor.forward; return /* tuple */[ - ofSortedArrayAux(v, 0, forwardLen), - ofSortedArrayRevAux(v, backward, size - forwardLen | 0) + fromSortedArrayAux(v, 0, forwardLen), + fromSortedArrayRevAux(v, backward, size - forwardLen | 0) ]; } else { return /* tuple */[ @@ -918,7 +918,7 @@ function addMutate(cmp, t, x) { } } -function ofArray(xs, cmp) { +function fromArray(xs, cmp) { var len = xs.length; if (len === 0) { return null; @@ -928,10 +928,10 @@ function ofArray(xs, cmp) { })); var result; if (next >= 0) { - result = ofSortedArrayAux(xs, 0, next); + result = fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ result = addMutate(cmp, result, xs[i]); @@ -990,9 +990,9 @@ exports.toList = toList; exports.checkInvariantInternal = checkInvariantInternal; exports.fillArray = fillArray; exports.toArray = toArray; -exports.ofSortedArrayAux = ofSortedArrayAux; -exports.ofSortedArrayRevAux = ofSortedArrayRevAux; -exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromSortedArrayAux = fromSortedArrayAux; +exports.fromSortedArrayRevAux = fromSortedArrayRevAux; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.has = has; exports.cmp = cmp; exports.eq = eq; @@ -1000,7 +1000,7 @@ exports.subset = subset; exports.get = get; exports.getUndefined = getUndefined; exports.getExn = getExn; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.addMutate = addMutate; exports.balMutate = balMutate; exports.removeMinAuxWithRootMutate = removeMinAuxWithRootMutate; diff --git a/lib/js/belt_internalAVLtree.js b/lib/js/belt_internalAVLtree.js index 0c5f2cedc7..bf9b3affb4 100644 --- a/lib/js/belt_internalAVLtree.js +++ b/lib/js/belt_internalAVLtree.js @@ -718,12 +718,12 @@ function valuesToArray(n) { } } -function ofSortedArrayRevAux(arr, off, len) { +function fromSortedArrayRevAux(arr, off, len) { if (len > 3 || len < 0) { var nl = len / 2 | 0; - var left = ofSortedArrayRevAux(arr, off, nl); + var left = fromSortedArrayRevAux(arr, off, nl); var match = arr[off - nl | 0]; - var right = ofSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); + var right = fromSortedArrayRevAux(arr, (off - nl | 0) - 1 | 0, (len - nl | 0) - 1 | 0); return create(left, match[0], match[1], right); } else { switch (len) { @@ -763,12 +763,12 @@ function ofSortedArrayRevAux(arr, off, len) { } } -function ofSortedArrayAux(arr, off, len) { +function fromSortedArrayAux(arr, off, len) { if (len > 3 || len < 0) { var nl = len / 2 | 0; - var left = ofSortedArrayAux(arr, off, nl); + var left = fromSortedArrayAux(arr, off, nl); var match = arr[off + nl | 0]; - var right = ofSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); + var right = fromSortedArrayAux(arr, (off + nl | 0) + 1 | 0, (len - nl | 0) - 1 | 0); return create(left, match[0], match[1], right); } else { switch (len) { @@ -808,8 +808,8 @@ function ofSortedArrayAux(arr, off, len) { } } -function ofSortedArrayUnsafe(arr) { - return ofSortedArrayAux(arr, 0, arr.length); +function fromSortedArrayUnsafe(arr) { + return fromSortedArrayAux(arr, 0, arr.length); } function cmpU(s1, s2, kcmp, vcmp) { @@ -1100,7 +1100,7 @@ function updateMutate(t, x, data, cmp) { } } -function ofArray(xs, cmp) { +function fromArray(xs, cmp) { var len = xs.length; if (len === 0) { return null; @@ -1110,10 +1110,10 @@ function ofArray(xs, cmp) { })); var result; if (next >= 0) { - result = ofSortedArrayAux(xs, 0, next); + result = fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ var match = xs[i]; @@ -1183,9 +1183,9 @@ exports.fillArray = fillArray; exports.toArray = toArray; exports.keysToArray = keysToArray; exports.valuesToArray = valuesToArray; -exports.ofSortedArrayAux = ofSortedArrayAux; -exports.ofSortedArrayRevAux = ofSortedArrayRevAux; -exports.ofSortedArrayUnsafe = ofSortedArrayUnsafe; +exports.fromSortedArrayAux = fromSortedArrayAux; +exports.fromSortedArrayRevAux = fromSortedArrayRevAux; +exports.fromSortedArrayUnsafe = fromSortedArrayUnsafe; exports.cmpU = cmpU; exports.cmp = cmp; exports.eqU = eqU; @@ -1195,7 +1195,7 @@ exports.getUndefined = getUndefined; exports.getWithDefault = getWithDefault; exports.getExn = getExn; exports.has = has; -exports.ofArray = ofArray; +exports.fromArray = fromArray; exports.updateMutate = updateMutate; exports.balMutate = balMutate; exports.removeMinAuxWithRootMutate = removeMinAuxWithRootMutate; diff --git a/lib/js/belt_internalMapInt.js b/lib/js/belt_internalMapInt.js index 4e488acf42..99ba05350f 100644 --- a/lib/js/belt_internalMapInt.js +++ b/lib/js/belt_internalMapInt.js @@ -343,7 +343,7 @@ function addMutate(t, x, data) { } } -function ofArray(xs) { +function fromArray(xs) { var len = xs.length; if (len === 0) { return Belt_internalAVLtree.empty; @@ -353,10 +353,10 @@ function ofArray(xs) { })); var result; if (next >= 0) { - result = Belt_internalAVLtree.ofSortedArrayAux(xs, 0, next); + result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = Belt_internalAVLtree.ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ var match = xs[i]; @@ -393,5 +393,5 @@ exports.eqAux = eqAux; exports.eqU = eqU; exports.eq = eq; exports.addMutate = addMutate; -exports.ofArray = ofArray; +exports.fromArray = fromArray; /* No side effect */ diff --git a/lib/js/belt_internalMapString.js b/lib/js/belt_internalMapString.js index 1b9a46ca76..5465bfebe1 100644 --- a/lib/js/belt_internalMapString.js +++ b/lib/js/belt_internalMapString.js @@ -343,7 +343,7 @@ function addMutate(t, x, data) { } } -function ofArray(xs) { +function fromArray(xs) { var len = xs.length; if (len === 0) { return Belt_internalAVLtree.empty; @@ -353,10 +353,10 @@ function ofArray(xs) { })); var result; if (next >= 0) { - result = Belt_internalAVLtree.ofSortedArrayAux(xs, 0, next); + result = Belt_internalAVLtree.fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = Belt_internalAVLtree.ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = Belt_internalAVLtree.fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ var match = xs[i]; @@ -393,5 +393,5 @@ exports.eqAux = eqAux; exports.eqU = eqU; exports.eq = eq; exports.addMutate = addMutate; -exports.ofArray = ofArray; +exports.fromArray = fromArray; /* No side effect */ diff --git a/lib/js/belt_internalSetInt.js b/lib/js/belt_internalSetInt.js index 5225b9a92f..d835a65064 100644 --- a/lib/js/belt_internalSetInt.js +++ b/lib/js/belt_internalSetInt.js @@ -185,7 +185,7 @@ function addMutate(t, x) { } } -function ofArray(xs) { +function fromArray(xs) { var len = xs.length; if (len === 0) { return Belt_internalAVLset.empty; @@ -193,10 +193,10 @@ function ofArray(xs) { var next = Belt_SortArrayInt.strictlySortedLength(xs); var result; if (next >= 0) { - result = Belt_internalAVLset.ofSortedArrayAux(xs, 0, next); + result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = Belt_internalAVLset.ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ result = addMutate(result, xs[i]); @@ -223,5 +223,5 @@ exports.get = get; exports.getUndefined = getUndefined; exports.getExn = getExn; exports.addMutate = addMutate; -exports.ofArray = ofArray; +exports.fromArray = fromArray; /* No side effect */ diff --git a/lib/js/belt_internalSetString.js b/lib/js/belt_internalSetString.js index 8b4f227587..06193cdd98 100644 --- a/lib/js/belt_internalSetString.js +++ b/lib/js/belt_internalSetString.js @@ -185,7 +185,7 @@ function addMutate(t, x) { } } -function ofArray(xs) { +function fromArray(xs) { var len = xs.length; if (len === 0) { return Belt_internalAVLset.empty; @@ -193,10 +193,10 @@ function ofArray(xs) { var next = Belt_SortArrayString.strictlySortedLength(xs); var result; if (next >= 0) { - result = Belt_internalAVLset.ofSortedArrayAux(xs, 0, next); + result = Belt_internalAVLset.fromSortedArrayAux(xs, 0, next); } else { next = -next | 0; - result = Belt_internalAVLset.ofSortedArrayRevAux(xs, next - 1 | 0, next); + result = Belt_internalAVLset.fromSortedArrayRevAux(xs, next - 1 | 0, next); } for(var i = next ,i_finish = len - 1 | 0; i <= i_finish; ++i){ result = addMutate(result, xs[i]); @@ -223,5 +223,5 @@ exports.get = get; exports.getUndefined = getUndefined; exports.getExn = getExn; exports.addMutate = addMutate; -exports.ofArray = ofArray; +exports.fromArray = fromArray; /* No side effect */