From 1ae192dc0eadf845adee92f8faeb9b54ac0a4c41 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Thu, 16 Apr 2020 03:36:54 -0700 Subject: [PATCH] [sledge] Use __LOC__ for Not_found_s Reviewed By: jvillard Differential Revision: D20863521 fbshipit-source-id: 11fa8e340 --- sledge/lib/import/list.ml | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/sledge/lib/import/list.ml b/sledge/lib/import/list.ml index 35e46f128..f85762171 100644 --- a/sledge/lib/import/list.ml +++ b/sledge/lib/import/list.ml @@ -18,9 +18,9 @@ let rec pp ?pre ?suf sep pp_elt fs = function | xs -> Format.fprintf fs "%( %)%a" sep (pp sep pp_elt) xs ) ; Option.iter suf ~f:(Format.fprintf fs) -let pop_exn = - let not_found = Not_found_s (Atom "pop_exn") in - function x :: xs -> (x, xs) | [] -> raise not_found +let pop_exn = function + | x :: xs -> (x, xs) + | [] -> raise (Not_found_s (Atom __LOC__)) let find_map_remove xs ~f = let rec find_map_remove_ ys = function @@ -71,15 +71,13 @@ let rev_map_unzip xs ~f = let y, z = f x in (y :: ys, z :: zs) ) -let remove_exn = - let not_found = Not_found_s (Atom "remove_exn") in - fun ?(equal = phys_equal) xs x -> - let rec remove_ ys = function - | [] -> raise not_found - | z :: xs -> - if equal x z then rev_append ys xs else remove_ (z :: ys) xs - in - remove_ [] xs +let remove_exn ?(equal = phys_equal) xs x = + let rec remove_ ys = function + | [] -> raise (Not_found_s (Atom __LOC__)) + | z :: xs -> + if equal x z then rev_append ys xs else remove_ (z :: ys) xs + in + remove_ [] xs let remove ?equal xs x = try Some (remove_exn ?equal xs x) with Not_found_s _ -> None