diff --git a/infer/src/base/IList.ml b/infer/src/base/IList.ml index 32c110f69..8f28efb72 100644 --- a/infer/src/base/IList.ml +++ b/infer/src/base/IList.ml @@ -7,6 +7,11 @@ * of patent rights can be found in the PATENTS file in the same directory. *) +type 'a t = 'a list [@@deriving compare] + +let equal cmp l1 l2 = + compare cmp l1 l2 = 0 + let exists = List.exists let filter = List.filter let find = List.find @@ -83,20 +88,6 @@ let rec drop_first n = function let drop_last n list = rev (drop_first n (rev list)) -(** Generic comparison of lists given a compare function for the elements of the list *) -let rec compare cmp l1 l2 = - match l1, l2 with - | [],[] -> 0 - | [], _ -> - 1 - | _, [] -> 1 - | x1:: l1', x2:: l2' -> - let n = cmp x1 x2 in - if n <> 0 then n else compare cmp l1' l2' - -(** Generic equality of lists given a compare function for the elements of the list *) -let equal cmp l1 l2 = - compare cmp l1 l2 = 0 - (** Returns (reverse input_list) *) let rec rev_with_acc acc = function | [] -> acc diff --git a/infer/src/base/IList.mli b/infer/src/base/IList.mli index 71574492b..cb37354db 100644 --- a/infer/src/base/IList.mli +++ b/infer/src/base/IList.mli @@ -7,11 +7,10 @@ * of patent rights can be found in the PATENTS file in the same directory. *) -(** Generic comparison of lists given a compare function for the elements of the list *) -val compare : ('a -> 'b -> int) -> 'a list -> 'b list -> int +type 'a t = 'a list [@@deriving compare] (** Generic equality of lists given a compare function for the elements of the list *) -val equal : ('a -> 'b -> int) -> 'a list -> 'b list -> bool +val equal : ('a -> 'a -> int) -> 'a list -> 'a list -> bool (** tail-recursive variant of List.append *) val append : 'a list -> 'a list -> 'a list