ppx_compare Typename

Reviewed By: cristianoc

Differential Revision: D4232370

fbshipit-source-id: 63292ea
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 5bd1cfab26
commit 17708ade33

@ -13,7 +13,10 @@ let module F = Format;
/** Named types. */ /** Named types. */
type t = type t =
| TN_csu Csu.t Mangled.t; | TN_csu Csu.t Mangled.t
[@@deriving compare];
let equal tn1 tn2 => compare tn1 tn2 == 0;
let to_string = let to_string =
fun fun
@ -25,19 +28,6 @@ let name =
fun fun
| TN_csu _ name => Mangled.to_string name; | TN_csu _ name => Mangled.to_string name;
let compare tn1 tn2 =>
switch (tn1, tn2) {
| (TN_csu csu1 n1, TN_csu csu2 n2) =>
let n = Csu.compare csu1 csu2;
if (n != 0) {
n
} else {
Mangled.compare n1 n2
}
};
let equal tn1 tn2 => compare tn1 tn2 == 0;
let module Java = { let module Java = {
let from_string class_name_str => let from_string class_name_str =>
TN_csu (Csu.Class Csu.Java) (Mangled.from_string class_name_str); TN_csu (Csu.Class Csu.Java) (Mangled.from_string class_name_str);
@ -50,9 +40,7 @@ let module Java = {
let java_lang_cloneable = from_string "java.lang.Cloneable"; let java_lang_cloneable = from_string "java.lang.Cloneable";
}; };
type typename_t = t;
let module Set = Set.Make { let module Set = Set.Make {
type t = typename_t; type nonrec t = t;
let compare = compare; let compare = compare;
}; };

@ -11,7 +11,12 @@ open! Utils;
/** Named types. */ /** Named types. */
type t = type t =
| TN_csu Csu.t Mangled.t; | TN_csu Csu.t Mangled.t
[@@deriving compare];
/** Equality for typenames */
let equal: t => t => bool;
/** convert the typename to a string */ /** convert the typename to a string */
@ -23,14 +28,6 @@ let pp: Format.formatter => t => unit;
/** name of the typename without qualifier */ /** name of the typename without qualifier */
let name: t => string; let name: t => string;
/** Comparison for typenames */
let compare: t => t => int;
/** Equality for typenames */
let equal: t => t => bool;
let module Java: { let module Java: {
/** Create a typename from a Java classname in the form "package.class" */ /** Create a typename from a Java classname in the form "package.class" */

Loading…
Cancel
Save