aboutsummaryrefslogtreecommitdiff
path: root/lib/util.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.ml')
-rw-r--r--lib/util.ml18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/util.ml b/lib/util.ml
index f04b2cf4b9..d28b0c25f3 100644
--- a/lib/util.ml
+++ b/lib/util.ml
@@ -3,6 +3,16 @@
open Pp
+(* Errors *)
+
+exception Anomaly of string * std_ppcmds (* System errors *)
+let anomaly string = raise (Anomaly(string,[< 'sTR string >]))
+let anomalylabstrm string pps = raise (Anomaly(string,pps))
+
+exception UserError of string * std_ppcmds (* User errors *)
+let error string = raise (UserError(string,[< 'sTR string >]))
+let errorlabstrm l pps = raise (UserError(l,pps))
+
(* Strings *)
let explode s =
@@ -51,6 +61,14 @@ let parse_section_path s =
let id,k = decoupe_kind n in
dirs,id,k
+(* Lists *)
+
+let intersect l1 l2 =
+ List.filter (fun x -> List.mem x l2) l1
+
+let subtract l1 l2 =
+ if l2 = [] then l1 else List.filter (fun x -> not (List.mem x l2)) l1
+
(* Pretty-printing *)
let pr_spc () = [< 'sPC >];;