12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(** A signature combining functionality that is commonly used for types that are intended
to act as names or identifiers.
Modules that satisfy [Identifiable] can be printed and parsed (both through string and
s-expression converters) and can be used in hash-based and comparison-based containers
(e.g., hashtables and maps).
This module also provides functors for conveniently constructing identifiable modules. *)open!ImportmoduleDefinitions=struct[%%template[@@@mode.defaultm=(global,local)][@@@alloc.defaulta=(heap,stack)]moduletypeArg=sigtypet[@@deriving(compare[@mode.explicitm]),hash,sexp]includeStringable.S[@alloca]withtypet:=t(** For registering the pretty printer. *)valmodule_name:stringend[@@@modality.defaultp=(portable,nonportable)]moduletypeArg_with_comparator=sigincludeArg[@modem][@alloca]includeComparator.S[@modalityp]withtypet:=tendmoduletypeS=sigtypet[@@derivinghash,sexp]includeStringable.S[@alloca]withtypet:=tincludeComparable.S[@modalityp][@modem]withtypet:=tincludePretty_printer.Swithtypet:=tvalhashable:tHashable.tend]endmoduletype%templateIdentifiable=sig@@portableincludemoduletypeofstructincludeDefinitionsend[@@@mode.defaultm=(global,local)][@@@alloc.defaulta=(heap,stack)](** Used for making an Identifiable module. Here's an example.
{[
module Id = struct
module T = struct
type t =
| A
| B
[@@deriving compare, hash, sexp]
let of_string s = t_of_sexp (sexp_of_string s)
let to_string t = string_of_sexp (sexp_of_t t)
let module_name = "My_library.Id"
end
include T
include Identifiable.Make (T)
end
]} *)module%template.portable[@modalityp]Make(M:Arg[@modem][@alloca]):S[@modem][@modalityp][@alloca]withtypet:=M.tmodule%template.portable[@modalityp]Make_using_comparator(M:Arg_with_comparator[@modem][@modalityp][@alloca]):S[@modem][@modalityp][@alloca]withtypet:=M.twithtypecomparator_witness:=M.comparator_witnessend