From ffba89de53251ff31b5e94f15188ecd8a1cae94d Mon Sep 17 00:00:00 2001 From: Jacques-Pascal Deplaix Date: Tue, 7 Nov 2017 12:05:43 +0100 Subject: [PATCH] Remove cross-module deps --- _oasis | 18 ++++++++++++------ _tags | 2 +- src/data/CCDeque.ml | 4 +++- src/data/CCMixmap.ml | 4 +++- src/data/CCMixtbl.ml | 4 +++- src/data/CCSimple_queue.ml | 10 +++++++--- src/data/CCTrie.ml | 6 +----- src/data/CCTrie.mli | 1 - src/iter/CCKTree.ml | 8 ++++++-- src/{core => pervasives}/CCPervasives.ml | 0 src/{core => pervasives}/CCPervasives.mli | 0 src/sexp/CCSexp_lex.mll | 4 +++- 12 files changed, 39 insertions(+), 22 deletions(-) rename src/{core => pervasives}/CCPervasives.ml (100%) rename src/{core => pervasives}/CCPervasives.mli (100%) diff --git a/_oasis b/_oasis index a9b0e648..ba1349ee 100644 --- a/_oasis +++ b/_oasis @@ -42,22 +42,28 @@ Library "containers" CCFun, CCHash, CCInt, CCBool, CCFloat, CCArray, CCRef, CCSet, CCOrd, CCRandom, CCString, CCHashtbl, CCMap, CCFormat, CCIO, CCInt64, CCChar, CCResult, CCParse, CCArray_slice, - CCListLabels, CCArrayLabels, CCEqual, CCPervasives, + CCListLabels, CCArrayLabels, CCEqual, Containers - BuildDepends: bytes, result + BuildDepends: bytes, result, containers.pervasives # BuildDepends: bytes, bisect_ppx +Library "containers_pervasives" + Path: src/pervasives + Modules: CCPervasives + FindlibParent: containers + FindlibName: pervasives + Library "containers_unix" Path: src/unix Modules: CCUnix - BuildDepends: containers, unix + BuildDepends: bytes, result, unix, containers.pervasives FindlibParent: containers FindlibName: unix Library "containers_sexp" Path: src/sexp Modules: CCSexp, CCSexp_lex - BuildDepends: containers + BuildDepends: bytes, result, containers.pervasives FindlibParent: containers FindlibName: sexp @@ -71,7 +77,7 @@ Library "containers_data" CCHashSet, CCBitField, CCHashTrie, CCWBTree, CCRAL, CCSimple_queue, CCImmutArray, CCHet, CCZipper - BuildDepends: containers + BuildDepends: bytes, containers.pervasives # BuildDepends: bytes, bisect_ppx FindlibParent: containers FindlibName: data @@ -79,7 +85,7 @@ Library "containers_data" Library "containers_iter" Path: src/iter Modules: CCKTree, CCKList, CCLazy_list - BuildDepends: containers + BuildDepends: containers.pervasives FindlibParent: containers FindlibName: iter diff --git a/_tags b/_tags index d482d357..5eebd7de 100644 --- a/_tags +++ b/_tags @@ -161,4 +161,4 @@ true: annot, bin_annot and not : warn(+a-4-44-58-60@8) true: no_alias_deps, safe_string, short_paths : nolabels -not : open(CCPervasives) +not : open(CCPervasives) diff --git a/src/data/CCDeque.ml b/src/data/CCDeque.ml index 00fe6a01..c5d89040 100644 --- a/src/data/CCDeque.ml +++ b/src/data/CCDeque.ml @@ -74,9 +74,11 @@ let is_zero_ n = match n.cell with | Two _ | Three _ -> false +let bool_eq (b1 : bool) b2 = Pervasives.(=) b1 b2 + let is_empty d = let res = d.size = 0 in - assert (CCBool.equal res (is_zero_ d.cur)); + assert (bool_eq res (is_zero_ d.cur)); res let push_front d x = diff --git a/src/data/CCMixmap.ml b/src/data/CCMixmap.ml index 83dbdcbe..d164dc1b 100644 --- a/src/data/CCMixmap.ml +++ b/src/data/CCMixmap.ml @@ -125,7 +125,9 @@ module Make(X : ORD) : S with type key = X.t = struct let mem ~inj x map = try - CCOpt.is_some (inj.get (M.find x map)) + match inj.get (M.find x map) with + | Some _ -> true + | None -> false with Not_found -> false let iter_keys ~f map = diff --git a/src/data/CCMixtbl.ml b/src/data/CCMixtbl.ml index 7b8e8f8b..854e3a77 100644 --- a/src/data/CCMixtbl.ml +++ b/src/data/CCMixtbl.ml @@ -86,7 +86,9 @@ let copy tbl = Hashtbl.copy tbl let mem ~inj tbl x = try - CCOpt.is_some (inj.get (Hashtbl.find tbl x)) + match inj.get (Hashtbl.find tbl x) with + | Some _ -> true + | None -> false with Not_found -> false (*$R diff --git a/src/data/CCSimple_queue.ml b/src/data/CCSimple_queue.ml index 67e02bbb..1eea0162 100644 --- a/src/data/CCSimple_queue.ml +++ b/src/data/CCSimple_queue.ml @@ -23,7 +23,11 @@ let make_ hd tl = match hd with | [] -> {hd=List.rev tl; tl=[] } | _::_ -> {hd; tl; } -let is_empty q = CCList.is_empty q.hd +let list_is_empty = function + | [] -> true + | _::_ -> false + +let is_empty q = list_is_empty q.hd let push x q = make_ q.hd (x :: q.tl) @@ -31,7 +35,7 @@ let snoc q x = push x q let peek_exn q = match q.hd with - | [] -> assert (CCList.is_empty q.tl); invalid_arg "Queue.peek" + | [] -> assert (list_is_empty q.tl); invalid_arg "Queue.peek" | x::_ -> x let peek q = match q.hd with @@ -40,7 +44,7 @@ let peek q = match q.hd with let pop_exn q = match q.hd with - | [] -> assert (CCList.is_empty q.tl); invalid_arg "Queue.peek" + | [] -> assert (list_is_empty q.tl); invalid_arg "Queue.peek" | x::hd' -> let q' = make_ hd' q.tl in x, q' diff --git a/src/data/CCTrie.ml b/src/data/CCTrie.ml index b3799adf..c5beeae7 100644 --- a/src/data/CCTrie.ml +++ b/src/data/CCTrie.ml @@ -19,7 +19,6 @@ module type WORD = sig val compare : char_ -> char_ -> int val to_seq : t -> char_ sequence val of_list : char_ list -> t - val equal : t -> t -> bool end module type S = sig @@ -528,7 +527,7 @@ module Make(W : WORD) | Empty -> 0 | Cons (_, t') -> size t' | Node (v, map) -> - let s = if CCOpt.is_none v then 0 else 1 in + let s = match v with None -> 0 | Some _ -> 1 in M.fold (fun _ t' acc -> size t' + acc) map s @@ -746,7 +745,6 @@ module MakeArray(X : ORDERED) = Make(struct let compare = X.compare let to_seq a k = Array.iter k a let of_list = Array.of_list - let equal = CCArray.equal (fun x y -> X.compare x y = 0) end) module MakeList(X : ORDERED) = Make(struct @@ -755,7 +753,6 @@ module MakeList(X : ORDERED) = Make(struct let compare = X.compare let to_seq a k = List.iter k a let of_list l = l - let equal = CCList.equal (fun x y -> X.compare x y = 0) end) module String = Make(struct @@ -767,5 +764,4 @@ module String = Make(struct let buf = Buffer.create (List.length l) in List.iter (fun c -> Buffer.add_char buf c) l; Buffer.contents buf - let equal = CCString.equal end) diff --git a/src/data/CCTrie.mli b/src/data/CCTrie.mli index 81f55d89..0cb34515 100644 --- a/src/data/CCTrie.mli +++ b/src/data/CCTrie.mli @@ -19,7 +19,6 @@ module type WORD = sig val compare : char_ -> char_ -> int val to_seq : t -> char_ sequence val of_list : char_ list -> t - val equal : t -> t -> bool end module type S = sig diff --git a/src/iter/CCKTree.ml b/src/iter/CCKTree.ml index 0d4489bb..3620ffca 100644 --- a/src/iter/CCKTree.ml +++ b/src/iter/CCKTree.ml @@ -141,13 +141,17 @@ module FQ = struct let empty = _make [] [] - let is_empty q = CCList.is_empty q.hd + let list_is_empty = function + | [] -> true + | _::_ -> false + + let is_empty q = list_is_empty q.hd let push q x = _make q.hd (x::q.tl) let pop_exn q = match q.hd with - | [] -> assert (CCList.is_empty q.tl); raise Empty + | [] -> assert (list_is_empty q.tl); raise Empty | x::hd' -> let q' = _make hd' q.tl in x, q' diff --git a/src/core/CCPervasives.ml b/src/pervasives/CCPervasives.ml similarity index 100% rename from src/core/CCPervasives.ml rename to src/pervasives/CCPervasives.ml diff --git a/src/core/CCPervasives.mli b/src/pervasives/CCPervasives.mli similarity index 100% rename from src/core/CCPervasives.mli rename to src/pervasives/CCPervasives.mli diff --git a/src/sexp/CCSexp_lex.mll b/src/sexp/CCSexp_lex.mll index 250f6c31..e56d2f75 100644 --- a/src/sexp/CCSexp_lex.mll +++ b/src/sexp/CCSexp_lex.mll @@ -20,9 +20,11 @@ | Escaped_int_1 of int | Escaped_int_2 of int + let char_eq (c1 : char) c2 = Pervasives.(=) c1 c2 + (* remove quotes + unescape *) let remove_quotes lexbuf s = - assert (CCChar.equal s.[0] '"' && CCChar.equal s.[String.length s - 1] '"'); + assert (char_eq s.[0] '"' && char_eq s.[String.length s - 1] '"'); let buf = Buffer.create (String.length s) in let st = ref Not_escaped in for i = 1 to String.length s-2 do