From 34d8de84ceb853c98bc80a0623f9afeae317d75f Mon Sep 17 00:00:00 2001 From: Gaetan Gilbert Date: Fri, 21 Apr 2017 19:25:49 +0200 Subject: Locally disable some warnings. --- lib/backtrace.ml | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/backtrace.ml b/lib/backtrace.ml index b3b8bdea2e..be9f40c1fb 100644 --- a/lib/backtrace.ml +++ b/lib/backtrace.ml @@ -5,6 +5,7 @@ (* // * This file is distributed under the terms of the *) (* * GNU Lesser General Public License Version 2.1 *) (***********************************************************************) +[@@@ocaml.warning "-37"] type raw_frame = | Known_location of bool (* is_raise *) -- cgit v1.2.3 From 8a3cd2fe699540f1ae5a56917d0f6b951f81d731 Mon Sep 17 00:00:00 2001 From: Gaetan Gilbert Date: Fri, 21 Apr 2017 19:29:35 +0200 Subject: Remove unused [rec] keywords --- lib/cWarnings.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/cWarnings.ml b/lib/cWarnings.ml index 2f569d2849..6a28d1e009 100644 --- a/lib/cWarnings.ml +++ b/lib/cWarnings.ml @@ -166,7 +166,7 @@ let normalize_flags_string s = let flags = normalize_flags ~silent:false flags in string_of_flags flags -let rec parse_warnings items = +let parse_warnings items = CList.iter (fun (status, name) -> set_status ~name status) items (* For compatibility, we accept "none" *) -- cgit v1.2.3 From 2826683746569b9d78aa01e319315ab554e1619b Mon Sep 17 00:00:00 2001 From: Gaetan Gilbert Date: Fri, 21 Apr 2017 19:36:45 +0200 Subject: Fix omitted labels in function calls --- lib/cWarnings.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/cWarnings.ml b/lib/cWarnings.ml index 6a28d1e009..71e02b3ba4 100644 --- a/lib/cWarnings.ml +++ b/lib/cWarnings.ml @@ -82,7 +82,7 @@ let set_all_warnings_status status = let set_category_status ~name status = let names = Hashtbl.find categories name in - List.iter (fun name -> set_warning_status name status) names + List.iter (fun name -> set_warning_status ~name status) names let is_all_keyword name = CString.equal name "all" let is_none_keyword s = CString.equal s "none" -- cgit v1.2.3 From 02d2f34e5c84f0169e884c07054a6fbfef9f365c Mon Sep 17 00:00:00 2001 From: Gaetan Gilbert Date: Fri, 21 Apr 2017 20:04:58 +0200 Subject: Remove some unused values and types --- lib/feedback.ml | 2 -- lib/stateid.ml | 1 - 2 files changed, 3 deletions(-) (limited to 'lib') diff --git a/lib/feedback.ml b/lib/feedback.ml index df6fe3a629..0846e419b2 100644 --- a/lib/feedback.ml +++ b/lib/feedback.ml @@ -40,8 +40,6 @@ type feedback = { contents : feedback_content; } -let default_route = 0 - (** Feeders *) let feeders : (int, feedback -> unit) Hashtbl.t = Hashtbl.create 7 diff --git a/lib/stateid.ml b/lib/stateid.ml index ae25735c5f..c153f0e808 100644 --- a/lib/stateid.ml +++ b/lib/stateid.ml @@ -32,7 +32,6 @@ let compare = Int.compare module Self = struct type t = int let compare = compare - let equal = equal end module Set = Set.Make(Self) -- cgit v1.2.3 From 87910d7be9bd50de4db80f70c6e287c7c7994460 Mon Sep 17 00:00:00 2001 From: Gaetan Gilbert Date: Tue, 25 Apr 2017 14:31:15 +0200 Subject: Fix 4.04 warnings --- lib/cErrors.ml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/cErrors.ml b/lib/cErrors.ml index 1c1ff7e2fd..b55fd80c68 100644 --- a/lib/cErrors.ml +++ b/lib/cErrors.ml @@ -121,12 +121,14 @@ end by inner functions during a [vernacinterp]. They should be handled only at the very end of interp, to be displayed to the user. *) +[@@@ocaml.warning "-52"] let noncritical = function | Sys.Break | Out_of_memory | Stack_overflow | Assert_failure _ | Match_failure _ | Anomaly _ | Timeout | Drop | Quit -> false | Invalid_argument "equal: functional value" -> false | _ -> true +[@@@ocaml.warning "+52"] (** Check whether an exception is handled *) -- cgit v1.2.3 From 7e28feadd6394483b6f527d5aed7d663e189596e Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Tue, 12 Jul 2016 23:26:44 +0200 Subject: Upgrading some local function as a general-purpose combinator Option.List.map. --- lib/option.ml | 10 ++++++++++ lib/option.mli | 6 ++++++ 2 files changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/option.ml b/lib/option.ml index fbb883d30a..f3047a3ca7 100644 --- a/lib/option.ml +++ b/lib/option.ml @@ -188,4 +188,14 @@ module List = |None -> find f t |x -> x + let map f l = + let rec aux f l = match l with + | [] -> [] + | x :: l -> + match f x with + | None -> raise Exit + | Some y -> y :: aux f l + in + try Some (aux f l) with Exit -> None + end diff --git a/lib/option.mli b/lib/option.mli index 5e085620e7..a336c895cc 100644 --- a/lib/option.mli +++ b/lib/option.mli @@ -123,4 +123,10 @@ module List : sig val flatten : 'a option list -> 'a list val find : ('a -> 'b option) -> 'a list -> 'b option + + (** [List.map f [a1;...;an]] is the list [Some [b1;...;bn]] if + for all i, there is a [bi] such that [f ai] is [Some bi]; it is + [None] if, for at least one i, [f ai] is [None]. *) + val map : ('a -> 'b option) -> 'a list -> 'b list option + end -- cgit v1.2.3 From 3f4c29f8258d627c7dbacbf1157825d96b146a6d Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 5 May 2017 17:34:43 +0200 Subject: Cosmetic: unifying style within option.ml. --- lib/option.ml | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'lib') diff --git a/lib/option.ml b/lib/option.ml index f3047a3ca7..50fdd079dc 100644 --- a/lib/option.ml +++ b/lib/option.ml @@ -20,24 +20,24 @@ let has_some = function | _ -> true let is_empty = function -| None -> true -| Some _ -> false + | None -> true + | Some _ -> false (** Lifting equality onto option types. *) let equal f x y = match x, y with -| None, None -> true -| Some x, Some y -> f x y -| _, _ -> false + | None, None -> true + | Some x, Some y -> f x y + | _, _ -> false let compare f x y = match x, y with -| None, None -> 0 -| Some x, Some y -> f x y -| None, Some _ -> -1 -| Some _, None -> 1 + | None, None -> 0 + | Some x, Some y -> f x y + | None, Some _ -> -1 + | Some _, None -> 1 let hash f = function -| None -> 0 -| Some x -> f x + | None -> 0 + | Some x -> f x exception IsNone @@ -57,13 +57,11 @@ let init b x = else None - (** [flatten x] is [Some y] if [x] is [Some (Some y)] and [None] otherwise. *) let flatten = function | Some (Some y) -> Some y | _ -> None - (** [append x y] is the first element of the concatenation of [x] and [y] seen as lists. *) let append o1 o2 = @@ -134,6 +132,7 @@ let cata f a = function | Some c -> f c | None -> a + (** {6 More Specific operations} ***) (** [default a x] is [y] if [x] is [Some y] and [a] otherwise. *) @@ -165,7 +164,6 @@ let lift2 f x y = | _,_ -> None - (** {6 Operations with Lists} *) module List = @@ -183,10 +181,10 @@ module List = | [] -> [] let rec find f = function - |[] -> None - |h :: t -> match f h with - |None -> find f t - |x -> x + | [] -> None + | h :: t -> match f h with + | None -> find f t + | x -> x let map f l = let rec aux f l = match l with -- cgit v1.2.3 From f24d8876837e2f9121064f496d89803f60ec2c71 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Fri, 5 May 2017 17:41:00 +0200 Subject: Documenting Option.List.find. --- lib/option.mli | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/option.mli b/lib/option.mli index a336c895cc..f06ad9f1d1 100644 --- a/lib/option.mli +++ b/lib/option.mli @@ -122,6 +122,9 @@ module List : sig [Some y] (in the same order). *) val flatten : 'a option list -> 'a list + (** [List.find f l] is the first [f a] different from [None], + scrolling through elements [a] of [l] in left-to-right order; + it is [None] if no such element exists. *) val find : ('a -> 'b option) -> 'a list -> 'b option (** [List.map f [a1;...;an]] is the list [Some [b1;...;bn]] if -- cgit v1.2.3