Skip to content

Commit bbfbe0f

Browse files
committed
fix many, many warnings
1 parent 77ff1ee commit bbfbe0f

File tree

14 files changed

+107
-115
lines changed

14 files changed

+107
-115
lines changed

src/core/CCArray.ml

Lines changed: 56 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,15 @@ let rec find_aux f a i =
139139
| None -> find_aux f a (i + 1)
140140
)
141141

142+
[@@@ocaml.warning "-32"]
143+
142144
let find_map f a = find_aux (fun _ -> f) a 0
143145
let find = find_map
144146
let find_map_i f a = find_aux f a 0
145147
let findi = find_map_i
146148

149+
[@@@ocaml.warning "+32"]
150+
147151
let find_idx p a =
148152
find_aux
149153
(fun i x ->
@@ -154,58 +158,76 @@ let find_idx p a =
154158
a 0
155159

156160
let max cmp a =
157-
if Array.length a = 0 then None
158-
else Some (
159-
fold
160-
(fun acc elt -> if cmp acc elt < 0 then elt else acc)
161-
a.(0)
162-
a)
161+
if Array.length a = 0 then
162+
None
163+
else
164+
Some
165+
(fold
166+
(fun acc elt ->
167+
if cmp acc elt < 0 then
168+
elt
169+
else
170+
acc)
171+
a.(0) a)
163172

164173
let max_exn cmp a =
165174
match max cmp a with
166-
| None -> invalid_arg "CCArray.max_exn"
167-
| Some elt -> elt
168-
175+
| None -> invalid_arg "CCArray.max_exn"
176+
| Some elt -> elt
169177

170178
let argmax cmp a =
171-
if Array.length a = 0 then None
172-
else Some (
173-
foldi
174-
(fun acc i elt -> if cmp a.(acc) elt < 0 then i else acc)
175-
0
176-
a)
179+
if Array.length a = 0 then
180+
None
181+
else
182+
Some
183+
(foldi
184+
(fun acc i elt ->
185+
if cmp a.(acc) elt < 0 then
186+
i
187+
else
188+
acc)
189+
0 a)
177190

178191
let argmax_exn cmp a =
179192
match argmax cmp a with
180-
| None -> invalid_arg "CCArray.argmax_exn"
181-
| Some elt -> elt
193+
| None -> invalid_arg "CCArray.argmax_exn"
194+
| Some elt -> elt
182195

183196
let min cmp a =
184-
if Array.length a = 0 then None
185-
else Some (
186-
fold
187-
(fun acc elt -> if cmp acc elt > 0 then elt else acc)
188-
a.(0)
189-
a)
197+
if Array.length a = 0 then
198+
None
199+
else
200+
Some
201+
(fold
202+
(fun acc elt ->
203+
if cmp acc elt > 0 then
204+
elt
205+
else
206+
acc)
207+
a.(0) a)
190208

191209
let min_exn cmp a =
192210
match min cmp a with
193-
| None -> invalid_arg "CCArray.min_exn"
194-
| Some elt -> elt
195-
211+
| None -> invalid_arg "CCArray.min_exn"
212+
| Some elt -> elt
196213

197214
let argmin cmp a =
198-
if Array.length a = 0 then None
199-
else Some (
200-
foldi
201-
(fun acc i elt -> if cmp a.(acc) elt > 0 then i else acc)
202-
0
203-
a)
215+
if Array.length a = 0 then
216+
None
217+
else
218+
Some
219+
(foldi
220+
(fun acc i elt ->
221+
if cmp a.(acc) elt > 0 then
222+
i
223+
else
224+
acc)
225+
0 a)
204226

205227
let argmin_exn cmp a =
206228
match argmin cmp a with
207-
| None -> invalid_arg "CCArray.argmin_exn"
208-
| Some elt -> elt
229+
| None -> invalid_arg "CCArray.argmin_exn"
230+
| Some elt -> elt
209231

210232
let filter_map f a =
211233
let rec aux acc i =

src/core/CCFloat.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ end
2727

2828
include Infix
2929

30+
[@@@ocaml.warning "-32"]
31+
3032
let nan = Stdlib.nan
3133
let infinity = Stdlib.infinity
3234
let neg_infinity = Stdlib.neg_infinity
@@ -68,6 +70,8 @@ let equal (a : float) b = a = b
6870
let hash : t -> int = Hashtbl.hash
6971
let compare (a : float) b = Stdlib.compare a b
7072

73+
[@@@ocaml.warning "+32"]
74+
7175
type 'a printer = Format.formatter -> 'a -> unit
7276
type 'a random_gen = Random.State.t -> 'a
7377

src/core/CCFun.ml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
(** {1 Basic Functions} *)
44

5+
[@@@ocaml.warning "-32"]
6+
57
let opaque_identity x = x
68

9+
[@@@ocaml.warning "+32"]
10+
711
(* import standard implementations, if any *)
812

913
include Sys
@@ -14,13 +18,10 @@ include CCShims_.Stdlib
1418
include Fun
1519

1620
[@@@else_]
21+
[@@@ocaml.warning "-32"]
1722

1823
external id : 'a -> 'a = "%identity"
1924

20-
let[@inline] flip f x y = f y x
21-
let[@inline] const x _ = x
22-
let[@inline] negate f x = not (f x)
23-
2425
let[@inline] protect ~finally f =
2526
try
2627
let x = f () in
@@ -30,6 +31,12 @@ let[@inline] protect ~finally f =
3031
finally ();
3132
raise e
3233

34+
[@@@ocaml.warning "+32"]
35+
36+
let[@inline] flip f x y = f y x
37+
let[@inline] const x _ = x
38+
let[@inline] negate f x = not (f x)
39+
3340
[@@@endif]
3441

3542
let compose f g x = g (f x)

src/core/CCInt.mli

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,14 @@ val to_float : t -> float
111111
(** [to_float] is the same as [float_of_int]
112112
@since 3.0*)
113113

114+
[@@@ocaml.warning "-32"]
115+
114116
val of_float : float -> t
115117
(** [to_float] is the same as [int_of_float]
116118
@since 3.0*)
117119

120+
[@@@ocaml.warning "+32"]
121+
118122
val to_string : t -> string
119123
(** [to_string x] returns the string representation of the integer [x], in signed decimal.
120124
@since 0.13 *)

src/core/CCList.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ open CCShims_
66

77
(* backport new functions from stdlib here *)
88

9+
[@@@ocaml.warning "-32"]
10+
911
let nth_opt l n =
1012
if n < 0 then invalid_arg "nth_opt";
1113
let rec aux l n =
@@ -46,6 +48,8 @@ let rec assq_opt x = function
4648
| (y, v) :: _ when Stdlib.( == ) x y -> Some v
4749
| _ :: tail -> assq_opt x tail
4850

51+
[@@@ocaml.warning "+32"]
52+
4953
(* end of backport *)
5054

5155
[@@@ifge 4.8]

src/core/CCList.mli

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ val is_empty : _ t -> bool
3333
(** [is_empty l] returns [true] iff [l = []].
3434
@since 0.11 *)
3535

36-
val map : ('a -> 'b) -> 'a t -> 'b t
37-
(** [map f [a0; a1; …; an]] applies function [f] in turn to [a0; a1; …; an].
38-
Safe version of {!List.map}. *)
39-
40-
val ( >|= ) : 'a t -> ('a -> 'b) -> 'b t
41-
(** [l >|= f] is the infix version of [map] with reversed arguments.
42-
@since 0.5 *)
43-
44-
val append : 'a t -> 'a t -> 'a t
45-
(** [append l1 l2] returns the list that is the concatenation of [l1] and [l2].
46-
Safe version of {!List.append}. *)
47-
4836
val cons_maybe : 'a option -> 'a t -> 'a t
4937
(** [cons_maybe (Some x) l] is [x :: l].
5038
[cons_maybe None l] is [l].
@@ -55,21 +43,6 @@ val cons' : 'a t -> 'a -> 'a t
5543
functions such as {!List.fold_left} or {!Array.fold_left}.
5644
@since 3.3 *)
5745

58-
val ( @ ) : 'a t -> 'a t -> 'a t
59-
(** [l1 @ l2] is like [append l1 l2].
60-
Concatenate the two lists [l1] and [l2]. *)
61-
62-
val filter : ('a -> bool) -> 'a t -> 'a t
63-
(** [filter p l] returns all the elements of the list [l]
64-
that satisfy the predicate [p]. The order of the elements
65-
in the input list [l] is preserved.
66-
Safe version of {!List.filter}. *)
67-
68-
val fold_right : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b
69-
(** [fold_right f [a1; …; an] b] is
70-
[f a1 (f a2 ( … (f an b) … ))].
71-
Safe version of {!List.fold_right}. *)
72-
7346
val fold_while : ('a -> 'b -> 'a * [ `Stop | `Continue ]) -> 'a -> 'b t -> 'a
7447
(** [fold_while f init l] folds until a stop condition via [('a, `Stop)] is
7548
indicated by the accumulator.
@@ -408,18 +381,9 @@ val mguard : bool -> unit t
408381
]}
409382
@since 3.1 *)
410383

411-
val ( <*> ) : ('a -> 'b) t -> 'a t -> 'b t
412-
(** [funs <*> l] is [product (fun f x -> f x) funs l]. *)
413-
414-
val ( <$> ) : ('a -> 'b) -> 'a t -> 'b t
415-
(** [(<$>)] is [map]. *)
416-
417384
val return : 'a -> 'a t
418385
(** [return x] is [x]. *)
419386

420-
val ( >>= ) : 'a t -> ('a -> 'b t) -> 'b t
421-
(** [l >>= f] is [flat_map f l]. *)
422-
423387
val take : int -> 'a t -> 'a t
424388
(** [take n l] takes the [n] first elements of the list [l], drop the rest. *)
425389

@@ -722,15 +686,6 @@ val range' : int -> int -> int t
722686
(** [range' i j] is like {!range} but the second bound [j] is excluded.
723687
For instance [range' 0 5 = [0;1;2;3;4]]. *)
724688

725-
val ( -- ) : int -> int -> int t
726-
(** [i -- j] is the list of integers from [i] to [j] included.
727-
Infix alias for [range]. *)
728-
729-
val ( --^ ) : int -> int -> int t
730-
(** [i --^ j] is the list of integers from [i] to [j] excluded.
731-
Infix alias for [range'].
732-
@since 0.17 *)
733-
734689
val replicate : int -> 'a -> 'a t
735690
(** [replicate n x] replicates the given element [x] [n] times. *)
736691

src/core/CCMap.ml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ module Make (O : Map.OrderedType) = struct
178178
(* backport functions from recent stdlib.
179179
they will be shadowed by inclusion of [S] if present. *)
180180

181+
[@@@ocaml.warning "-32"]
182+
181183
let union f a b =
182184
M.merge
183185
(fun k v1 v2 ->
@@ -230,6 +232,8 @@ module Make (O : Map.OrderedType) = struct
230232
| None -> raise Not_found
231233
| Some (k, v) -> k, v
232234

235+
[@@@ocaml.warning "+32"]
236+
233237
(* === include M.
234238
This will shadow some values depending on OCaml's current version
235239
=== *)

src/core/CCParse.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,6 @@ let parsing what p =
338338
}
339339

340340
let empty = { run = (fun st ~ok ~err:_ -> ok st ()) }
341-
let nop = empty
342341
let any_char = { run = (fun st ~ok ~err -> consume_ st ~ok ~err) }
343342

344343
let char c : _ t =
@@ -811,8 +810,6 @@ let split_list_at_most ~on_char n : slice list t =
811810
in
812811
loop [] n
813812

814-
let split_list ~on_char : _ t = split_list_at_most ~on_char max_int
815-
816813
let split_2 ~on_char : _ t =
817814
split_list_at_most ~on_char 3 >>= function
818815
| [ a; b ] -> return (a, b)
@@ -948,8 +945,6 @@ let parse_file_exn p file =
948945
| Error e -> raise (ParseError e)
949946

950947
module U = struct
951-
let sep_ = sep
952-
953948
let list ?(start = "[") ?(stop = "]") ?(sep = ";") p =
954949
string start *> skip_white
955950
*> sep_until

src/core/CCResult.ml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,6 @@ let get_or_failwith = function
108108
| Ok x -> x
109109
| Error msg -> failwith msg
110110

111-
let get_lazy default_fn x =
112-
match x with
113-
| Ok x -> x
114-
| Error e -> default_fn e
115-
116111
let map_or f e ~default =
117112
match e with
118113
| Ok x -> f x

src/core/CCResult.mli

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ val get_exn : ('a, _) t -> 'a
9494
val get_or : ('a, _) t -> default:'a -> 'a
9595
(** [get_or e ~default] returns [x] if [e = Ok x], [default] otherwise. *)
9696

97-
val get_lazy : ('e -> 'a) -> ('a, 'e) t -> 'a
98-
(** [get_lazy f e] returns [x] if [e = Ok x], [f msg] if [e = Error msg].
99-
This is similar to {!CCOption.get_lazy}.
100-
@since 3.0 *)
101-
10297
val get_or_failwith : ('a, string) t -> 'a
10398
(** [get_or_failwith e] returns [x] if [e = Ok x], fails otherwise.
10499
@raise Failure with [msg] if [e = Error msg].

0 commit comments

Comments
 (0)