removed many warnings

This commit is contained in:
Simon Cruanes 2014-11-08 01:28:42 +01:00
parent af58399ca7
commit 24b441579c
17 changed files with 59 additions and 59 deletions

View file

@ -225,7 +225,7 @@ let _shuffle _rand_int a i j =
let _choose a i j st = let _choose a i j st =
if i>=j then raise Not_found; if i>=j then raise Not_found;
a.(i+Random.int (j-i)) a.(i+Random.State.int st (j-i))
let _pp ~sep pp_item buf a i j = let _pp ~sep pp_item buf a i j =
for k = i to j - 1 do for k = i to j - 1 do
@ -283,7 +283,7 @@ let iteri = Array.iteri
let blit = Array.blit let blit = Array.blit
let reverse_in_place a = let reverse_in_place a =
_reverse_in_place a 0 (Array.length a) _reverse_in_place a 0 ~len:(Array.length a)
(*$T (*$T
reverse_in_place [| |]; true reverse_in_place [| |]; true
@ -464,7 +464,7 @@ module Sub = struct
let copy a = Array.sub a.arr a.i (length a) let copy a = Array.sub a.arr a.i (length a)
let sub a i len = make a.arr (a.i + i) len let sub a i len = make a.arr ~len:(a.i + i) len
let equal eq a b = let equal eq a b =
length a = length b && _equal eq a.arr a.i a.j b.arr b.i b.j length a = length b && _equal eq a.arr a.i a.j b.arr b.i b.j

View file

@ -170,7 +170,7 @@ let choose l =
(* print errors on the buffer *) (* print errors on the buffer *)
let rec print buf l = match l with let rec print buf l = match l with
| `Ok _ :: _ -> assert false | `Ok _ :: _ -> assert false
| (`Error x)::((y::xs) as l) -> | (`Error x)::((_::_) as l) ->
Buffer.add_string buf x; Buffer.add_string buf x;
Buffer.add_string buf ", "; Buffer.add_string buf ", ";
print buf l print buf l
@ -205,7 +205,7 @@ module Traverse(M : MONAD) = struct
let sequence_m m = map_m (fun x->x) m let sequence_m m = map_m (fun x->x) m
let fold_m f acc e = match e with let fold_m f acc e = match e with
| `Error s -> M.return acc | `Error _ -> M.return acc
| `Ok x -> f acc x >>= fun y -> M.return y | `Ok x -> f acc x >>= fun y -> M.return y
let rec retry_m n f = match n with let rec retry_m n f = match n with

View file

@ -68,7 +68,7 @@ let rec cons : 'a. 'a -> 'a t -> 'a t
| Shallow (Two (y,z)) -> Shallow (Three (x,y,z)) | Shallow (Two (y,z)) -> Shallow (Three (x,y,z))
| Shallow (Three (y,z,z')) -> | Shallow (Three (y,z,z')) ->
_deep 4 (Two (x,y)) _empty (Two (z,z')) _deep 4 (Two (x,y)) _empty (Two (z,z'))
| Deep (_, Zero, middle, tl) -> assert false | Deep (_, Zero, _middle, _tl) -> assert false
| Deep (n,One y, middle, tl) -> _deep (n+1) (Two (x,y)) middle tl | Deep (n,One y, middle, tl) -> _deep (n+1) (Two (x,y)) middle tl
| Deep (n,Two (y,z), middle, tl) -> _deep (n+1)(Three (x,y,z)) middle tl | Deep (n,Two (y,z), middle, tl) -> _deep (n+1)(Three (x,y,z)) middle tl
| Deep (n,Three (y,z,z'), lazy q', tail) -> | Deep (n,Three (y,z,z'), lazy q', tail) ->
@ -81,7 +81,7 @@ let rec snoc : 'a. 'a t -> 'a -> 'a t
| Shallow (Two (y,z)) -> Shallow (Three (y,z,x)) | Shallow (Two (y,z)) -> Shallow (Three (y,z,x))
| Shallow (Three (y,z,z')) -> | Shallow (Three (y,z,z')) ->
_deep 4 (Two (y,z)) _empty (Two (z',x)) _deep 4 (Two (y,z)) _empty (Two (z',x))
| Deep (_,hd, middle, Zero) -> assert false | Deep (_,_hd, _middle, Zero) -> assert false
| Deep (n,hd, middle, One y) -> _deep (n+1) hd middle (Two(y,x)) | Deep (n,hd, middle, One y) -> _deep (n+1) hd middle (Two(y,x))
| Deep (n,hd, middle, Two (y,z)) -> _deep (n+1) hd middle (Three(y,z,x)) | Deep (n,hd, middle, Two (y,z)) -> _deep (n+1) hd middle (Three(y,z,x))
| Deep (n,hd, lazy q', Three (y,z,z')) -> | Deep (n,hd, lazy q', Three (y,z,z')) ->
@ -131,7 +131,7 @@ let rec take_back_exn : 'a. 'a t -> 'a t * 'a
| Shallow (One x) -> empty, x | Shallow (One x) -> empty, x
| Shallow (Two (x,y)) -> _single x, y | Shallow (Two (x,y)) -> _single x, y
| Shallow (Three (x,y,z)) -> Shallow (Two(x,y)), z | Shallow (Three (x,y,z)) -> Shallow (Two(x,y)), z
| Deep (_, hd, middle, Zero) -> assert false | Deep (_, _hd, _middle, Zero) -> assert false
| Deep (n, hd, lazy q', One x) -> | Deep (n, hd, lazy q', One x) ->
if is_empty q' if is_empty q'
then Shallow hd, x then Shallow hd, x
@ -206,7 +206,7 @@ let rec nth_exn : 'a. int -> 'a t -> 'a
| 1, Shallow (Three (_,x,_)) -> x | 1, Shallow (Three (_,x,_)) -> x
| 2, Shallow (Three (_,_,x)) -> x | 2, Shallow (Three (_,_,x)) -> x
| _, Shallow _ -> raise Not_found | _, Shallow _ -> raise Not_found
| _, Deep (n, l, q, r) -> | _, Deep (_, l, q, r) ->
if i<_size_digit l if i<_size_digit l
then _nth_digit i l then _nth_digit i l
else else

View file

@ -170,7 +170,7 @@ module Make(X : HASHABLE) = struct
| Empty -> () | Empty -> ()
| Key (_, _, h_k) when _dib tbl h_k i = 0 -> | Key (_, _, h_k) when _dib tbl h_k i = 0 ->
() (* stop *) () (* stop *)
| Key (k, v, h_k) as bucket -> | Key (_k, _v, h_k) as bucket ->
assert (_dib tbl h_k i > 0); assert (_dib tbl h_k i > 0);
(* shift backward *) (* shift backward *)
tbl.arr.(_pred tbl i) <- bucket; tbl.arr.(_pred tbl i) <- bucket;

View file

@ -671,7 +671,7 @@ let drop_while p gen =
| Yield -> | Yield ->
begin match gen () with begin match gen () with
| None -> state := Stop; None | None -> state := Stop; None
| (Some x) as res -> res | Some _ as res -> res
end end
in next in next
@ -1088,7 +1088,7 @@ let sorted_merge_n ?(cmp=Pervasives.compare) l =
let round_robin ?(n=2) gen = let round_robin ?(n=2) gen =
(* array of queues, together with their index *) (* array of queues, together with their index *)
let qs = Array.init n (fun i -> Queue.create ()) in let qs = Array.init n (fun _ -> Queue.create ()) in
let cur = ref 0 in let cur = ref 0 in
(* get next element for the i-th queue *) (* get next element for the i-th queue *)
let rec next i = let rec next i =
@ -1128,7 +1128,7 @@ let round_robin ?(n=2) gen =
when they are consumed evenly *) when they are consumed evenly *)
let tee ?(n=2) gen = let tee ?(n=2) gen =
(* array of queues, together with their index *) (* array of queues, together with their index *)
let qs = Array.init n (fun i -> Queue.create ()) in let qs = Array.init n (fun _ -> Queue.create ()) in
let finished = ref false in (* is [gen] exhausted? *) let finished = ref false in (* is [gen] exhausted? *)
(* get next element for the i-th queue *) (* get next element for the i-th queue *)
let rec next i = let rec next i =
@ -1139,7 +1139,7 @@ let tee ?(n=2) gen =
else Queue.pop qs.(i) else Queue.pop qs.(i)
(* consume one more element *) (* consume one more element *)
and get_next i = match gen() with and get_next i = match gen() with
| (Some x) as res -> | Some _ as res ->
for j = 0 to n-1 do for j = 0 to n-1 do
if j <> i then Queue.push res qs.(j) if j <> i then Queue.push res qs.(j)
done; done;

View file

@ -415,7 +415,7 @@ module Seq = struct
try _yield (input_line ic) try _yield (input_line ic)
with End_of_file -> _stop() with End_of_file -> _stop()
let words g = let words _g =
failwith "words: not implemented yet" failwith "words: not implemented yet"
(* TODO: state machine that goes: (* TODO: state machine that goes:
- 0: read input chunk - 0: read input chunk

View file

@ -199,14 +199,14 @@ module Dot = struct
let mk_id format = let mk_id format =
let buf = Buffer.create 64 in let buf = Buffer.create 64 in
Printf.kbprintf Printf.kbprintf
(fun fmt -> `Id (Buffer.contents buf)) (fun _ -> `Id (Buffer.contents buf))
buf buf
format format
let mk_label format = let mk_label format =
let buf = Buffer.create 64 in let buf = Buffer.create 64 in
Printf.kbprintf Printf.kbprintf
(fun fmt -> `Label(Buffer.contents buf)) (fun _ -> `Label(Buffer.contents buf))
buf buf
format format
@ -287,6 +287,6 @@ module Dot = struct
Printf.bprintf buf "}\n"; Printf.bprintf buf "}\n";
() ()
let pp_single name buf t = pp buf (singleton name t) let pp_single name buf t = pp buf (singleton ~name t)
end end

View file

@ -167,7 +167,7 @@ module Make(K : OrderedType)(V : OrderedType) = struct
let union m1 m2 = let union m1 m2 =
M.merge M.merge
(fun k v1 v2 -> match v1, v2 with (fun _k v1 v2 -> match v1, v2 with
| None, None -> None | None, None -> None
| Some set1, Some set2 -> Some (S.union set1 set2) | Some set1, Some set2 -> Some (S.union set1 set2)
| Some set, None | Some set, None
@ -176,7 +176,7 @@ module Make(K : OrderedType)(V : OrderedType) = struct
let inter m1 m2 = let inter m1 m2 =
M.merge M.merge
(fun k v1 v2 -> match v1, v2 with (fun _k v1 v2 -> match v1, v2 with
| None, _ | None, _
| _, None -> None | _, None -> None
| Some set1, Some set2 -> | Some set1, Some set2 ->
@ -188,7 +188,7 @@ module Make(K : OrderedType)(V : OrderedType) = struct
let diff m1 m2 = let diff m1 m2 =
M.merge M.merge
(fun k v1 v2 -> match v1, v2 with (fun _k v1 v2 -> match v1, v2 with
| None, _ -> None | None, _ -> None
| Some set, None -> Some set | Some set, None -> Some set
| Some set1, Some set2 -> | Some set1, Some set2 ->

View file

@ -117,7 +117,7 @@ module Make(O : Set.OrderedType) = struct
let union m1 m2 = let union m1 m2 =
M.merge M.merge
(fun x n1 n2 -> match n1, n2 with (fun _x n1 n2 -> match n1, n2 with
| None, None -> assert false | None, None -> assert false
| Some n, None | Some n, None
| None, Some n -> Some n | None, Some n -> Some n
@ -134,7 +134,7 @@ module Make(O : Set.OrderedType) = struct
let intersection m1 m2 = let intersection m1 m2 =
M.merge M.merge
(fun x n1 n2 -> match n1, n2 with (fun _x n1 n2 -> match n1, n2 with
| None, None -> assert false | None, None -> assert false
| Some _, None | Some _, None
| None, Some _ -> None | None, Some _ -> None
@ -143,10 +143,10 @@ module Make(O : Set.OrderedType) = struct
let diff m1 m2 = let diff m1 m2 =
M.merge M.merge
(fun x n1 n2 -> match n1, n2 with (fun _x n1 n2 -> match n1, n2 with
| None, None -> assert false | None, None -> assert false
| Some n1, None -> Some n1 | Some n1, None -> Some n1
| None, Some n2 -> None | None, Some _n2 -> None
| Some n1, Some n2 -> | Some n1, Some n2 ->
if n1 > n2 if n1 > n2
then Some (n1 - n2) then Some (n1 - n2)

View file

@ -294,7 +294,7 @@ module Make(H : HashedType) : S with type key = H.t = struct
(fun k v2 -> (fun k v2 ->
if not (mem t1 k) then match f k None (Some v2) with if not (mem t1 k) then match f k None (Some v2) with
| None -> () | None -> ()
| Some v' -> Table.replace tbl k v2); | Some _ -> Table.replace tbl k v2);
ref (Table tbl) ref (Table tbl)
let add_seq init seq = let add_seq init seq =

View file

@ -38,7 +38,7 @@ type 'a t = Buffer.t -> 'a -> unit
(** {2 Combinators} *) (** {2 Combinators} *)
let silent buf _ = () let silent _buf _ = ()
let unit buf () = Buffer.add_string buf "()" let unit buf () = Buffer.add_string buf "()"
let int buf i = Buffer.add_string buf (string_of_int i) let int buf i = Buffer.add_string buf (string_of_int i)
@ -49,7 +49,7 @@ let float buf f = Buffer.add_string buf (string_of_float f)
let list ?(start="[") ?(stop="]") ?(sep=", ") pp buf l = let list ?(start="[") ?(stop="]") ?(sep=", ") pp buf l =
let rec pp_list l = match l with let rec pp_list l = match l with
| x::((y::xs) as l) -> | x::((_::_) as l) ->
pp buf x; pp buf x;
Buffer.add_string buf sep; Buffer.add_string buf sep;
pp_list l pp_list l
@ -116,14 +116,14 @@ let to_string pp x =
let sprintf format = let sprintf format =
let buffer = Buffer.create 64 in let buffer = Buffer.create 64 in
Printf.kbprintf Printf.kbprintf
(fun fmt -> Buffer.contents buffer) (fun _fmt -> Buffer.contents buffer)
buffer buffer
format format
let fprintf oc format = let fprintf oc format =
let buffer = Buffer.create 64 in let buffer = Buffer.create 64 in
Printf.kbprintf Printf.kbprintf
(fun fmt -> Buffer.output_buffer oc buffer) (fun _fmt -> Buffer.output_buffer oc buffer)
buffer buffer
format format

View file

@ -211,7 +211,7 @@ module Make(W : WORD) = struct
let _remove_sub c t = match t with let _remove_sub c t = match t with
| Empty -> t | Empty -> t
| Path ([], _) -> assert false | Path ([], _) -> assert false
| Path (c'::l, t') -> | Path (c'::_, _) ->
if W.compare c c' = 0 if W.compare c c' = 0
then Empty then Empty
else t else t
@ -357,7 +357,7 @@ module Make(W : WORD) = struct
| Some v -> f acc v | Some v -> f acc v
in in
M.fold M.fold
(fun c t' acc -> fold_values f acc t') (fun _c t' acc -> fold_values f acc t')
map acc map acc
let iter_values f t = fold_values (fun () x -> f x) () t let iter_values f t = fold_values (fun () x -> f x) () t

View file

@ -437,7 +437,7 @@ let of_array a =
let of_list l = match l with let of_list l = match l with
| [] -> create() | [] -> create()
| x::l' -> | x::_ ->
let v = create_with ~capacity:(List.length l + 5) x in let v = create_with ~capacity:(List.length l + 5) x in
List.iter (push v) l; List.iter (push v) l;
v v

View file

@ -79,7 +79,6 @@ let parse chars =
read_list (t::acc) (* next *) read_list (t::acc) (* next *)
| Some (Genlex.Kwd "]") -> | Some (Genlex.Kwd "]") ->
read_list (t::acc) (* next *) read_list (t::acc) (* next *)
| Some (Genlex.Kwd "]") -> List.rev acc (* yield *)
| _ -> raise (Stream.Error "expected ','")) | _ -> raise (Stream.Error "expected ','"))
and read_pairs acc = and read_pairs acc =
match peek tokens with match peek tokens with
@ -163,7 +162,8 @@ let rec pp fmt t =
let to_string t = let to_string t =
let buf = Buffer.create 16 in let buf = Buffer.create 16 in
Format.bprintf buf "%a@?" pp t; let fmt = Format.formatter_of_buffer buf in
Format.fprintf fmt "%a@?" pp t;
Buffer.contents buf Buffer.contents buf
(** {2 Utils *) (** {2 Utils *)

View file

@ -36,7 +36,7 @@ let _minus pos1 pos2 = _move pos1 (- pos2.x) (- pos2.y)
let _move_x pos x = _move pos x 0 let _move_x pos x = _move pos x 0
let _move_y pos y = _move pos 0 y let _move_y pos y = _move pos 0 y
let _string_len = ref String.length let _string_len = ref Bytes.length
let set_string_len f = _string_len := f let set_string_len f = _string_len := f
@ -61,11 +61,11 @@ module Output = struct
mutable buf_len : int; mutable buf_len : int;
} }
and buf_line = { and buf_line = {
mutable bl_str : string; mutable bl_str : Bytes.t;
mutable bl_len : int; mutable bl_len : int;
} }
let _make_line _ = {bl_str=""; bl_len=0} let _make_line _ = {bl_str=Bytes.empty; bl_len=0}
let _ensure_lines buf i = let _ensure_lines buf i =
if i >= Array.length buf.buf_lines if i >= Array.length buf.buf_lines
@ -78,8 +78,8 @@ module Output = struct
let _ensure_line line i = let _ensure_line line i =
if i >= !_string_len line.bl_str if i >= !_string_len line.bl_str
then ( then (
let str' = String.make (2 * i + 5) ' ' in let str' = Bytes.make (2 * i + 5) ' ' in
String.blit line.bl_str 0 str' 0 line.bl_len; Bytes.blit line.bl_str 0 str' 0 line.bl_len;
line.bl_str <- str'; line.bl_str <- str';
) )
@ -88,7 +88,7 @@ module Output = struct
_ensure_line buf.buf_lines.(pos.y) pos.x; _ensure_line buf.buf_lines.(pos.y) pos.x;
buf.buf_len <- max buf.buf_len (pos.y+1); buf.buf_len <- max buf.buf_len (pos.y+1);
let line = buf.buf_lines.(pos.y) in let line = buf.buf_lines.(pos.y) in
line.bl_str.[pos.x] <- c; Bytes.set line.bl_str pos.x c;
line.bl_len <- max line.bl_len (pos.x+1) line.bl_len <- max line.bl_len (pos.x+1)
let _buf_put_sub_string buf pos s s_i s_len = let _buf_put_sub_string buf pos s s_i s_len =
@ -100,7 +100,7 @@ module Output = struct
line.bl_len <- max line.bl_len (pos.x+s_len) line.bl_len <- max line.bl_len (pos.x+s_len)
let _buf_put_string buf pos s = let _buf_put_string buf pos s =
_buf_put_sub_string buf pos s 0 (!_string_len s) _buf_put_sub_string buf pos s 0 (!_string_len (Bytes.unsafe_of_string s))
(* create a new buffer *) (* create a new buffer *)
let make_buffer () = let make_buffer () =
@ -121,7 +121,7 @@ module Output = struct
for i = 0 to buf.buf_len - 1 do for i = 0 to buf.buf_len - 1 do
for k = 1 to indent do Buffer.add_char buffer ' ' done; for k = 1 to indent do Buffer.add_char buffer ' ' done;
let line = buf.buf_lines.(i) in let line = buf.buf_lines.(i) in
Buffer.add_substring buffer line.bl_str 0 line.bl_len; Buffer.add_substring buffer (Bytes.unsafe_to_string line.bl_str) 0 line.bl_len;
Buffer.add_char buffer '\n'; Buffer.add_char buffer '\n';
done; done;
Buffer.contents buffer Buffer.contents buffer
@ -238,7 +238,7 @@ module Box = struct
| Empty -> origin | Empty -> origin
| Text l -> | Text l ->
let width = List.fold_left let width = List.fold_left
(fun acc line -> max acc (!_string_len line)) 0 l (fun acc line -> max acc (!_string_len (Bytes.unsafe_of_string line))) 0 l
in in
{ x=width; y=List.length l; } { x=width; y=List.length l; }
| Frame t -> | Frame t ->
@ -337,7 +337,7 @@ let tree ?(indent=1) node children =
let children = let children =
List.filter List.filter
(function (function
| {Box.shape=Box.Empty} -> false | {Box.shape=Box.Empty; _} -> false
| _ -> true | _ -> true
) children ) children
in in
@ -384,10 +384,10 @@ let rec _render ?(offset=origin) ?expected_size ~out b pos =
Output.put_char out (_move pos (x+1) (y+1)) '+'; Output.put_char out (_move pos (x+1) (y+1)) '+';
Output.put_char out (_move pos 0 (y+1)) '+'; Output.put_char out (_move pos 0 (y+1)) '+';
Output.put_char out (_move pos (x+1) 0) '+'; Output.put_char out (_move pos (x+1) 0) '+';
_write_hline out (_move_x pos 1) x; _write_hline ~out (_move_x pos 1) x;
_write_hline out (_move pos 1 (y+1)) x; _write_hline ~out (_move pos 1 (y+1)) x;
_write_vline out (_move_y pos 1) y; _write_vline ~out (_move_y pos 1) y;
_write_vline out (_move pos (x+1) 1) y; _write_vline ~out (_move pos (x+1) 1) y;
_render ~out b' (_move pos 1 1) _render ~out b' (_move pos 1 1)
| Box.Pad (dim, b') -> | Box.Pad (dim, b') ->
let expected_size = Box.size b in let expected_size = Box.size b in

View file

@ -72,7 +72,7 @@ we go toward the bottom (same order as a printer) *)
val origin : position val origin : position
(** Initial position *) (** Initial position *)
val set_string_len : (string -> int) -> unit val set_string_len : (Bytes.t -> int) -> unit
(** Set which function is used to compute string length. Typically (** Set which function is used to compute string length. Typically
to be used with a unicode-sensitive length function *) to be used with a unicode-sensitive length function *)

View file

@ -26,10 +26,10 @@ let test_mutation =
return (s,i,c) return (s,i,c)
) in ) in
let test (s,i,c) = let test (s,i,c) =
let s' = String.copy s in let s' = Bytes.of_string s in
s'.[i] <- c; Bytes.set s' i c;
let a = Levenshtein.of_string ~limit:1 s in let a = Levenshtein.of_string ~limit:1 s in
Levenshtein.match_with a s' Levenshtein.match_with a (Bytes.to_string s')
in in
let name = "mutating s.[i] into s' still accepted by automaton(s)" in let name = "mutating s.[i] into s' still accepted by automaton(s)" in
QCheck.mk_test ~name ~size:(fun (s,_,_)->String.length s) gen test QCheck.mk_test ~name ~size:(fun (s,_,_)->String.length s) gen test