From 5dbb4a6fc2015f2d23253d30ef70c5ad3f67560d Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 17 Mar 2020 09:05:27 -0700 Subject: [PATCH] [sledge] Dedup Set signature Reviewed By: ngorogiannis Differential Revision: D20482769 fbshipit-source-id: a9dd43b53 --- sledge/lib/import/set.ml | 43 +----------------------------- sledge/lib/import/set.mli | 43 +----------------------------- sledge/lib/import/set_intf.ml | 49 +++++++++++++++++++++++++++++++++++ sledge/lib/llair.ml | 15 ++++------- 4 files changed, 56 insertions(+), 94 deletions(-) create mode 100644 sledge/lib/import/set_intf.ml diff --git a/sledge/lib/import/set.ml b/sledge/lib/import/set.ml index ee22f31ba..783975da5 100644 --- a/sledge/lib/import/set.ml +++ b/sledge/lib/import/set.ml @@ -6,48 +6,7 @@ *) open Import0 -open Vector.Infix - -module type S = sig - type elt - type t - - val compare : t -> t -> int - val equal : t -> t -> bool - val sexp_of_t : t -> Sexp.t - val t_of_sexp : (Sexp.t -> elt) -> Sexp.t -> t - val pp : elt pp -> t pp - val pp_diff : elt pp -> (t * t) pp - - (* initial constructors *) - val empty : t - val of_ : elt -> t - val of_option : elt option -> t - val of_list : elt list -> t - val of_vector : elt vector -> t - - (* constructors *) - val add : t -> elt -> t - val add_option : elt option -> t -> t - val add_list : elt list -> t -> t - val remove : t -> elt -> t - val filter : t -> f:(elt -> bool) -> t - val union : t -> t -> t - val union_list : t list -> t - val diff : t -> t -> t - val inter : t -> t -> t - val diff_inter : t -> t -> t * t - - (* queries *) - val is_empty : t -> bool - val mem : t -> elt -> bool - val is_subset : t -> of_:t -> bool - val disjoint : t -> t -> bool - val max_elt : t -> elt option - - (* traversals *) - val fold : t -> init:'s -> f:('s -> elt -> 's) -> 's -end +include Set_intf module Make (Elt : OrderedType) : S with type elt = Elt.t = struct module S = Caml.Set.Make (Elt) diff --git a/sledge/lib/import/set.mli b/sledge/lib/import/set.mli index af2d61243..4ef862c8d 100644 --- a/sledge/lib/import/set.mli +++ b/sledge/lib/import/set.mli @@ -6,46 +6,5 @@ *) open Import0 - -module type S = sig - type elt - type t - - val compare : t -> t -> int - val equal : t -> t -> bool - val sexp_of_t : t -> Sexp.t - val t_of_sexp : (Sexp.t -> elt) -> Sexp.t -> t - val pp : elt pp -> t pp - val pp_diff : elt pp -> (t * t) pp - - (* initial constructors *) - val empty : t - val of_ : elt -> t - val of_option : elt option -> t - val of_list : elt list -> t - val of_vector : elt Vector.t -> t - - (* constructors *) - val add : t -> elt -> t - val add_option : elt option -> t -> t - val add_list : elt list -> t -> t - val remove : t -> elt -> t - val filter : t -> f:(elt -> bool) -> t - val union : t -> t -> t - val union_list : t list -> t - val diff : t -> t -> t - val inter : t -> t -> t - val diff_inter : t -> t -> t * t - - (* queries *) - val is_empty : t -> bool - val mem : t -> elt -> bool - val is_subset : t -> of_:t -> bool - val disjoint : t -> t -> bool - val max_elt : t -> elt option - - (* traversals *) - val fold : t -> init:'s -> f:('s -> elt -> 's) -> 's -end - +include module type of Set_intf module Make (Elt : OrderedType) : S with type elt = Elt.t diff --git a/sledge/lib/import/set_intf.ml b/sledge/lib/import/set_intf.ml new file mode 100644 index 000000000..8709f100f --- /dev/null +++ b/sledge/lib/import/set_intf.ml @@ -0,0 +1,49 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open Import0 + +module type S = sig + type elt + type t + + val compare : t -> t -> int + val equal : t -> t -> bool + val sexp_of_t : t -> Sexp.t + val t_of_sexp : (Sexp.t -> elt) -> Sexp.t -> t + val pp : elt pp -> t pp + val pp_diff : elt pp -> (t * t) pp + + (* initial constructors *) + val empty : t + val of_ : elt -> t + val of_option : elt option -> t + val of_list : elt list -> t + val of_vector : elt Vector.t -> t + + (* constructors *) + val add : t -> elt -> t + val add_option : elt option -> t -> t + val add_list : elt list -> t -> t + val remove : t -> elt -> t + val filter : t -> f:(elt -> bool) -> t + val union : t -> t -> t + val union_list : t list -> t + val diff : t -> t -> t + val inter : t -> t -> t + val diff_inter : t -> t -> t * t + + (* queries *) + val is_empty : t -> bool + val mem : t -> elt -> bool + val is_subset : t -> of_:t -> bool + val disjoint : t -> t -> bool + val max_elt : t -> elt option + + (* traversals *) + val fold : t -> init:'s -> f:('s -> elt -> 's) -> 's +end diff --git a/sledge/lib/llair.ml b/sledge/lib/llair.ml index e2c87a942..db11fceec 100644 --- a/sledge/lib/llair.ml +++ b/sledge/lib/llair.ml @@ -376,18 +376,13 @@ end compute unique sort_index ids *) module Block_label = struct module T = struct - module T0 = struct - type t = block [@@deriving sexp_of] + type t = block [@@deriving sexp_of] - let compare x y = - [%compare: string * Global.t] (x.lbl, x.parent.name) - (y.lbl, y.parent.name) + let compare x y = + [%compare: string * Global.t] (x.lbl, x.parent.name) + (y.lbl, y.parent.name) - let hash b = [%hash: string * Global.t] (b.lbl, b.parent.name) - end - - include T0 - include Comparator.Make (T0) + let hash b = [%hash: string * Global.t] (b.lbl, b.parent.name) end include T