diff --git a/src/core/CCEqual.ml b/src/core/CCEqual.ml index 769dbbb7..56c3ca5c 100644 --- a/src/core/CCEqual.ml +++ b/src/core/CCEqual.ml @@ -7,10 +7,10 @@ type 'a t = 'a -> 'a -> bool let poly = Pervasives.(=) -let int : int t = CCInt.equal -let string : string t = CCString.equal -let bool : bool t = CCBool.equal -let float : float t = CCFloat.equal +let int : int t = Pervasives.(=) +let string : string t = Pervasives.(=) +let bool : bool t = Pervasives.(=) +let float : float t = Pervasives.(=) let unit () () = true let rec list f l1 l2 = match l1, l2 with diff --git a/src/core/CCInt.ml b/src/core/CCInt.ml index f4b8adb0..ff0b9d41 100644 --- a/src/core/CCInt.ml +++ b/src/core/CCInt.ml @@ -77,7 +77,8 @@ let floor_div a n = let rem a n = let y = a mod n in - if not (CCBool.equal (y < 0) (n < 0)) && y <> 0 then + let bool_neq (a : bool) b = Pervasives.(<>) a b in + if bool_neq (y < 0) (n < 0) && y <> 0 then y + n else y diff --git a/src/core/CCParse.ml b/src/core/CCParse.ml index 01511e0a..c4e9bf81 100644 --- a/src/core/CCParse.ml +++ b/src/core/CCParse.ml @@ -81,13 +81,15 @@ let fail_ ~err st msg = let b = (st.lnum, st.cnum, None) :: st.branch in err (ParseError (b, msg)) +let char_eq (a : char) b = Pervasives.(=) a b + let next st ~ok ~err = if st.i = String.length st.str then fail_ st ~err (const_ "unexpected end of input") else ( let c = st.str.[st.i] in st.i <- st.i + 1; - if CCChar.equal c '\n' + if char_eq c '\n' then (st.lnum <- st.lnum + 1; st.cnum <- 1) else st.cnum <- st.cnum + 1; ok c @@ -146,7 +148,7 @@ let char c = let msg = Printf.sprintf "expected '%c'" c in fun st ~ok ~err -> next st ~err - ~ok:(fun c' -> if CCChar.equal c c' then ok c else fail_ ~err st (const_ msg)) + ~ok:(fun c' -> if char_eq c c' then ok c else fail_ ~err st (const_ msg)) let char_if p st ~ok ~err = next st ~err @@ -161,10 +163,12 @@ let chars_if p st ~ok ~err:_ = while not (is_done st) && p (cur st) do junk_ st; incr len done; ok (String.sub st.str i !len) +let string_is_empty (s : string) = Pervasives.(=) s "" + let chars1_if p st ~ok ~err = chars_if p st ~err ~ok:(fun s -> - if CCString.is_empty s + if string_is_empty s then fail_ ~err st (const_ "unexpected sequence of chars") else ok s) @@ -231,7 +235,7 @@ let string s st ~ok ~err = else next st ~err ~ok:(fun c -> - if CCChar.equal c s.[i] + if char_eq c s.[i] then check (i+1) else fail_ ~err st (fun () -> Printf.sprintf "expected \"%s\"" s)) in @@ -386,7 +390,7 @@ module U = struct skip_white <* string stop let int = - chars1_if (fun c -> is_num c || CCChar.equal c '-') + chars1_if (fun c -> is_num c || char_eq c '-') >>= fun s -> try return (int_of_string s) with Failure _ -> fail "expected an int" diff --git a/src/core/CCRandom.ml b/src/core/CCRandom.ml index 0bf23101..1de7dd1b 100644 --- a/src/core/CCRandom.ml +++ b/src/core/CCRandom.ml @@ -108,6 +108,7 @@ let _diff_list ~last l = in diff_list [] l +let int_cmp (a : int) b = Pervasives.compare a b (* Partition of an int into [len] integers uniformly. We first sample (len-1) points from the set {1,..i-1} without replacement. @@ -118,7 +119,7 @@ let _diff_list ~last l = let split_list i ~len st = if len <= 1 then invalid_arg "Random.split_list"; if i >= len then - let xs = sample_without_replacement ~compare:CCInt.compare (len-1) (int_range 1 (i-1)) st in + let xs = sample_without_replacement ~compare:int_cmp (len-1) (int_range 1 (i-1)) st in _diff_list ( 0::xs ) ~last:i else None @@ -221,7 +222,8 @@ let uniformity_test ?(size_hint=10) k rng st = let confidence = 4. in let std = confidence *. (sqrt (kf *. variance)) in let predicate _key n acc = - CCFloat.Infix.(acc && abs_float (average -. float_of_int n) < std) in + let (<) (a : float) b = Pervasives.(<) a b in + acc && abs_float (average -. float_of_int n) < std in Hashtbl.fold predicate histogram true (*$T split_list diff --git a/src/threads/CCTimer.ml b/src/threads/CCTimer.ml index 8bd5a7d6..9ad6e2c4 100644 --- a/src/threads/CCTimer.ml +++ b/src/threads/CCTimer.ml @@ -6,7 +6,10 @@ type job = | Job : float * (unit -> 'a) -> job -open CCFloat.Infix +let (<=) (a : float) b = Pervasives.(<=) a b +let (>=) (a : float) b = Pervasives.(>=) a b +let (<) (a : float) b = Pervasives.(<) a b +let (>) (a : float) b = Pervasives.(>) a b module TaskHeap = CCHeap.Make(struct type t = job