12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091open!CoreopenStable_witness.ExportincludeCommon_intfmoduleMake(T:Types.Type)(Basis:Basis)=structmoduleStable=struct(* Our stable serializations are not straightforward, as they parse and canonicalize
strings. Rather than opening only [Core.Core_stable], we use as much of [Core] as
we need, and make sure to write thorough tests for the stable serializations. *)moduleV1=structincludeTlet[@cold]raise_invalid~namestring=raise_s[%sexp(Printf.sprintf"%s.%s: invalid string"Basis.module_namename:string),(string:string)];;let[@cold]raise_non_canonical~namestring=raise_s[%sexp(Printf.sprintf"%s.%s: non-canonical representation"Basis.module_namename:string),(string:string)];;letof_stringstring=ifnot(Basis.is_validstring)thenraise_invalid~name:"of_string"stringelseifnot(Basis.is_canonicalstring)thenExpert.unchecked_of_canonical_string(Basis.canonicalizestring)elseExpert.unchecked_of_canonical_stringstring;;letinvariantt=letstring=to_stringtinifnot(Basis.is_validstring)thenraise_invalid~name:"invariant"stringelseifnot(Basis.is_canonicalstring)thenraise_non_canonical~name:"invariant"string;;includeBinable.Of_stringable_with_uuid(structtypenonrect=tletof_string=of_stringletto_string=to_stringletcaller_identity=Basis.caller_identityend)includeSexpable.Of_stringable(structtypenonrect=tletof_string=of_stringletto_string=to_stringend)(* Path types are serialized using [of_string/to_string], and derive their stability
from the fact that string is a primitive type. *)letstable_witness=Stable_witness.of_serializable[%stable_witness:string]of_stringto_string;;includeIdentifiable.Make_using_comparator(structtypenonrect=t[@@derivingbin_io,compare,hash,sexp]typenonreccomparator_witness=comparator_witnessletof_string=of_stringletto_string=to_stringletcomparator=comparatorletmodule_name=Basis.module_nameend)(* Include [T] again to make sure we export the fast versions of any underlying
operations. *)includeTendendincludeStable.V1letarg_type=Command.Arg_type.createof_string~complete:(fun(_:Univ_map.t)~part->tryBasis.autocompletepartwith|(_:exn)(* don't mask exceptions during inline tests *)whennotPpx_inline_test_lib.am_running->[]);;end