From 5bd1cfab26070b6de1eed7131682ad88f71bae90 Mon Sep 17 00:00:00 2001 From: Josh Berdine Date: Tue, 29 Nov 2016 16:32:23 -0800 Subject: [PATCH] ppx_compare Mangled Reviewed By: cristianoc Differential Revision: D4232369 fbshipit-source-id: 3d4dcc3 --- infer/src/IR/Mangled.re | 23 ++--------------------- infer/src/IR/Mangled.rei | 6 +----- 2 files changed, 3 insertions(+), 26 deletions(-) diff --git a/infer/src/IR/Mangled.re b/infer/src/IR/Mangled.re index 1cd33c12b..658e8a6cd 100644 --- a/infer/src/IR/Mangled.re +++ b/infer/src/IR/Mangled.re @@ -16,24 +16,7 @@ open! Utils; /** Module for Mangled Names */ let module F = Format; -type t = {plain: string, mangled: option string}; - -let mangled_compare so1 so2 => - switch (so1, so2) { - | (None, None) => 0 - | (None, Some _) => (-1) - | (Some _, None) => 1 - | (Some s1, Some s2) => string_compare s1 s2 - }; - -let compare pn1 pn2 => { - let n = string_compare pn1.plain pn2.plain; - if (n != 0) { - n - } else { - mangled_compare pn1.mangled pn2.mangled - } -}; +type t = {plain: string, mangled: option string} [@@deriving compare]; let equal pn1 pn2 => compare pn1 pn2 == 0; @@ -81,9 +64,7 @@ let from_package_class package_name class_name => /** Pretty print a mangled name */ let pp f pn => F.fprintf f "%s" (to_string pn); -type mangled_t = t; - let module MangledSet = Set.Make { - type t = mangled_t; + type nonrec t = t; let compare = compare; }; diff --git a/infer/src/IR/Mangled.rei b/infer/src/IR/Mangled.rei index b387d511c..cf75079fb 100644 --- a/infer/src/IR/Mangled.rei +++ b/infer/src/IR/Mangled.rei @@ -16,11 +16,7 @@ open! Utils; /** Module for Mangled Names */ /** Type of mangled names */ -type t; - - -/** Comparison for mangled names */ -let compare: t => t => int; +type t [@@deriving compare]; /** Equality for mangled names */