a signature for opaque identifier types.
There used to be a functor Identifiable.Of_sexpable
, but we removed it because it
encouraged a terrible implementation of Identifiable.S
. In particular, hash
,
compare
, and bin_io
were all built by converting the type to a sexp, and then to a
string.
One should use Identifiable.Make
instead. Here is what a use might look like:
module Id = struct
module T = struct
type t = A | B with bin_io, compare, sexp
let hash (t : t) = Hashtbl.hash t
include Sexpable.To_stringable (struct type nonrec t = t with sexp end)
end
include T
include Identifiable.Make (T)
end
We also removed Identifiable.Of_stringable
, which wasn't as obviously bad as
Of_sexpable
. But it still used the string as an intermediate, which is often the
wrong choice -- especially for compare
and bin_io
, that can be generated by
preprocessors.