123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739open!ImportopenMap_intfmoduleList=List0moduleSymmetric_diff_element=structmoduleStable=structmoduleV1=structtype('k,'v)t='k*[`Leftof'v|`Rightof'v|`Unequalof'v*'v][@@derivingbin_io,compare,sexp]let%expect_test_=print_endline[%bin_digest:(int,string)t];[%expect{| 00674be9fe8dfe9e9ad476067d7d8101 |}];;letmap(k,diff)~f1~f2=letk=f1kinletdiff=matchdiffwith|`Leftv->`Left(f2v)|`Rightv->`Right(f2v)|`Unequal(v1,v2)->`Unequal(f2v1,f2v2)ink,diff;;letmap_datat~f=mapt~f1:Fn.id~f2:fletleft(_key,diff)=matchdiffwith|`Leftx|`Unequal(x,_)->Somex|`Right_->None;;letright(_key,diff)=matchdiffwith|`Rightx|`Unequal(_,x)->Somex|`Left_->None;;endendincludeStable.V1endmoduleMerge_element=Base.Map.Merge_elementmoduleContinue_or_stop=Base.Map.Continue_or_stopmoduleFinished_or_unfinished=Base.Map.Finished_or_unfinishedtype('k,'cmp)comparator=(moduleComparator.Swithtypet='kandtypecomparator_witness='cmp)letto_comparator(typekcmp)((moduleM):(k,cmp)Comparator.Module.t)=M.comparatorletof_comparator(typekcmp)comparator:(k,cmp)Comparator.Module.t=(modulestructtypet=ktypecomparator_witness=cmpletcomparator=comparatorend);;moduleFor_quickcheck=structletgen_tree~comparatork_genv_gen=Base_quickcheck.Generator.map_tree_using_comparator~comparatork_genv_gen;;letquickcheck_generator~comparatork_genv_gen=Base_quickcheck.Generator.map_t_m(of_comparatorcomparator)k_genv_gen;;letobs_treek_obsv_obs=Base_quickcheck.Observer.map_treek_obsv_obsletshr_tree~comparatork_shrv_shr=Base_quickcheck.Shrinker.map_tree_using_comparator~comparatork_shrv_shr;;endletquickcheck_generator=Base_quickcheck.Generator.map_t_mletquickcheck_observer=Base_quickcheck.Observer.map_tletquickcheck_shrinker=Base_quickcheck.Shrinker.map_tmoduleUsing_comparator=structincludeMap.Using_comparatorincludeFor_quickcheckletof_hashtbl_exn~comparatorhashtbl=matchof_iteri~comparator~iteri:(Hashtbl.iterihashtbl)with|`Okmap->map|`Duplicate_keykey->Error.failwiths~here:[%here]"Map.of_hashtbl_exn: duplicate key"keycomparator.sexp_of_t;;lettree_of_hashtbl_exn~comparatorhashtbl=to_tree(of_hashtbl_exn~comparatorhashtbl);;letkey_set~comparatort=Base.Set.Using_comparator.of_sorted_array_unchecked~comparator(List.to_array(keyst));;letkey_set_of_tree~comparatort=key_set~comparator(of_tree~comparatort)letof_key_setkey_set~f=of_sorted_array_unchecked~comparator:(Base.Set.comparatorkey_set)(Array.map(Base.Set.to_arraykey_set)~f:(funkey->key,fkey));;lettree_of_key_setkey_set~f=to_tree(of_key_setkey_set~f)endmoduleAccessors=structinclude(Map.Using_comparator:Map.Accessors3withtype('a,'b,'c)t:=('a,'b,'c)Map.twithtype('a,'b,'c)tree:=('a,'b,'c)Tree.t)letvalidate~nameft=Validate.alist~namef(to_alistt)letvalidatei~nameft=Validate.list~name:(Fn.composenamefst)f(to_alistt)letquickcheck_observerkv=quickcheck_observerkvletquickcheck_shrinkerkv=quickcheck_shrinkerkvletkey_sett=Using_comparator.key_sett~comparator:(Using_comparator.comparatort)endletkey_sett=Using_comparator.key_set~comparator:(Using_comparator.comparatort)tletof_key_set=Using_comparator.of_key_setlethash_fold_direct=Using_comparator.hash_fold_directletcomparator=Using_comparator.comparatorletcomparator_s=Base.Map.comparator_stype'kkey='ktype'ccmp='cinclude(structincludeMapletvalidate~nameft=Validate.alist~namef(to_alistt)letvalidatei~nameft=Validate.list~name:(Fn.composenamefst)f(to_alistt)letof_treem=Map.Using_comparator.of_tree~comparator:(to_comparatorm)letto_tree=Map.Using_comparator.to_treeend:sigtype('a,'b,'c)t=('a,'b,'c)Map.tincludeMap.Creators_genericwithtype('a,'b,'c)options:=('a,'b,'c)Map.With_first_class_module.twithtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)Tree.twithtype'kkey:='kkeywithtype'ccmp:='ccmpincludeMap.Accessors3withtype('a,'b,'c)t:=('a,'b,'c)twithtype('a,'b,'c)tree:=('a,'b,'c)Tree.tvalvalidate:name:('k->string)->'vValidate.check->('k,'v,_)tValidate.checkvalvalidatei:name:('kkey->string)->('kkey*'v)Validate.check->('k,'v,_)tValidate.checkend)moduleEmpty_without_value_restriction=Using_comparator.Empty_without_value_restrictionletfind_or_errortkey=letcomparator=comparatortinmatchfindtkeywith|Somedata->Okdata|None->letsexp_of_key=comparator.sexp_of_tinOr_error.error_s[%message"key not found"~_:(key:key)];;letmerge_skewed=Map.merge_skewedletof_hashtbl_exnmt=Using_comparator.of_hashtbl_exn~comparator:(to_comparatorm)tmoduleCreators(Key:Comparator.S1):sigtype('a,'b,'c)t_=('aKey.t,'b,Key.comparator_witness)ttype('a,'b,'c)tree=('a,'b,Key.comparator_witness)Tree.ttype('a,'b,'c)options=('a,'b,'c)Without_comparator.tvalt_of_sexp:(Base.Sexp.t->'aKey.t)->(Base.Sexp.t->'b)->Base.Sexp.t->('a,'b,_)t_includeCreators_genericwithtype('a,'b,'c)t:=('a,'b,'c)t_withtype('a,'b,'c)tree:=('a,'b,'c)treewithtype'akey:='aKey.twithtype'acmp:=Key.comparator_witnesswithtype('a,'b,'c)options:=('a,'b,'c)optionsend=structtype('a,'b,'c)options=('a,'b,'c)Without_comparator.tletcomparator=Key.comparatortype('a,'b,'c)t_=('aKey.t,'b,Key.comparator_witness)ttype('a,'b,'c)tree=('a,'b,Key.comparator_witness)Tree.tmoduleM_empty=Empty_without_value_restriction(Key)letempty=M_empty.emptyletof_treetree=Using_comparator.of_tree~comparatortreeletsingletonkv=Using_comparator.singleton~comparatorkvletof_sorted_array_uncheckedarray=Using_comparator.of_sorted_array_unchecked~comparatorarray;;letof_sorted_arrayarray=Using_comparator.of_sorted_array~comparatorarrayletof_increasing_iterator_unchecked~len~f=Using_comparator.of_increasing_iterator_unchecked~comparator~len~f;;letof_increasing_sequenceseq=Using_comparator.of_increasing_sequence~comparatorseqletof_sequenceseq=Using_comparator.of_sequence~comparatorseqletof_sequence_or_errorseq=Using_comparator.of_sequence_or_error~comparatorseqletof_sequence_exnseq=Using_comparator.of_sequence_exn~comparatorseqletof_sequence_multiseq=Using_comparator.of_sequence_multi~comparatorseqletof_sequence_foldseq~init~f=Using_comparator.of_sequence_fold~comparatorseq~init~f;;letof_sequence_reduceseq~f=Using_comparator.of_sequence_reduce~comparatorseq~fletof_alistalist=Using_comparator.of_alist~comparatoralistletof_alist_or_erroralist=Using_comparator.of_alist_or_error~comparatoralistletof_alist_exnalist=Using_comparator.of_alist_exn~comparatoralistletof_hashtbl_exnhashtbl=Using_comparator.of_hashtbl_exn~comparatorhashtblletof_alist_multialist=Using_comparator.of_alist_multi~comparatoralistletof_alist_foldalist~init~f=Using_comparator.of_alist_fold~comparatoralist~init~f;;letof_alist_reducealist~f=Using_comparator.of_alist_reduce~comparatoralist~fletof_iteri~iteri=Using_comparator.of_iteri~comparator~iteriletof_iteri_exn~iteri=Using_comparator.of_iteri_exn~comparator~iterilett_of_sexpk_of_sexpv_of_sexpsexp=Using_comparator.t_of_sexp_direct~comparatork_of_sexpv_of_sexpsexp;;letof_key_setkey_set~f=Using_comparator.of_key_setkey_set~fletmap_keyst~f=Using_comparator.map_keys~comparatort~fletmap_keys_exnt~f=Using_comparator.map_keys_exn~comparatort~fletquickcheck_generatorgen_kgen_v=Using_comparator.quickcheck_generator~comparatorgen_kgen_v;;endmoduleMake_tree_S1(Key:Comparator.S1)=structopenTreeletcomparator=Key.comparatorletsexp_of_t=sexp_of_tlett_of_sexpabc=t_of_sexp_directabc~comparatorletempty=empty_without_value_restrictionletof_treetree=treeletsingletona=singletona~comparatorletof_sorted_array_uncheckeda=of_sorted_array_uncheckeda~comparatorletof_sorted_arraya=of_sorted_arraya~comparatorletof_increasing_iterator_unchecked~len~f=of_increasing_iterator_unchecked~len~f~comparator;;letof_increasing_sequenceseq=of_increasing_sequence~comparatorseqletof_sequences=of_sequences~comparatorletof_sequence_or_errors=of_sequence_or_errors~comparatorletof_sequence_exns=of_sequence_exns~comparatorletof_sequence_multis=of_sequence_multis~comparatorletof_sequence_folds~init~f=of_sequence_folds~init~f~comparatorletof_sequence_reduces~f=of_sequence_reduces~f~comparatorletof_alista=of_alista~comparatorletof_alist_or_errora=of_alist_or_errora~comparatorletof_alist_exna=of_alist_exna~comparatorletof_hashtbl_exna=Using_comparator.tree_of_hashtbl_exna~comparatorletof_alist_multia=of_alist_multia~comparatorletof_alist_folda~init~f=of_alist_folda~init~f~comparatorletof_alist_reducea~f=of_alist_reducea~f~comparatorletof_iteri~iteri=of_iteri~iteri~comparatorletof_iteri_exn~iteri=of_iteri_exn~iteri~comparatorletof_key_set=Using_comparator.tree_of_key_setletto_treet=tletinvariantsa=invariantsa~comparatorletis_emptya=is_emptyaletlengtha=lengthaletseta~key~data=seta~key~data~comparatorletadda~key~data=adda~key~data~comparatorletadd_exna~key~data=add_exna~key~data~comparatorletadd_multia~key~data=add_multia~key~data~comparatorletremove_multiab=remove_multiab~comparatorletfind_multiab=find_multiab~comparatorletchangeab~f=changeab~f~comparatorletupdateab~f=updateab~f~comparatorletfind_exnab=find_exnab~comparatorletfindab=findab~comparatorletremoveab=removeab~comparatorletmemab=memab~comparatorletiter_keys=iter_keysletiter=iterletiteri=iteriletiteri_until=iteri_untilletiter2ab~f=iter2ab~f~comparatorletmap=mapletmapi=mapiletfold=foldletfold_until=fold_untilletfold_right=fold_rightletfold2ab~init~f=fold2ab~init~f~comparatorletfilter_keysa~f=filter_keysa~f~comparatorletfiltera~f=filtera~f~comparatorletfilteria~f=filteria~f~comparatorletfilter_mapa~f=filter_mapa~f~comparatorletfilter_mapia~f=filter_mapia~f~comparatorletpartition_mapit~f=partition_mapit~f~comparatorletpartition_mapt~f=partition_mapt~f~comparatorletpartitioni_tft~f=partitioni_tft~f~comparatorletpartition_tft~f=partition_tft~f~comparatorletcombine_errorst=combine_errorst~comparatorletcompare_directabc=compare_directabc~comparatorletequalabc=equalabc~comparatorletkeys=keysletdata=dataletto_alist=to_alistletvalidate~nameft=Validate.alist~namef(to_alistt)letvalidatei~nameft=Validate.list~name:(Fn.composenamefst)f(to_alistt)letsymmetric_diffab~data_equal=symmetric_diffab~data_equal~comparatorletfold_symmetric_diffab~data_equal~init~f=fold_symmetric_diffab~data_equal~f~init~comparator;;letmergeab~f=mergeab~f~comparatorletmerge_skewedab~combine=merge_skewedab~combine~comparatorletmin_elt=min_eltletmin_elt_exn=min_elt_exnletmax_elt=max_eltletmax_elt_exn=max_elt_exnletfor_all=for_allletfor_alli=for_alliletexists=existsletexistsi=existsiletcount=countletcounti=countiletsplitab=splitab~comparatorletappend~lower_part~upper_part=append~lower_part~upper_part~comparatorletsubranget~lower_bound~upper_bound=subranget~lower_bound~upper_bound~comparator;;letfold_range_inclusivet~min~max~init~f=fold_range_inclusivet~min~max~init~f~comparator;;letrange_to_alistt~min~max=range_to_alistt~min~max~comparatorletclosest_keyabc=closest_keyabc~comparatorletnth=nthletnth_exn=nth_exnletrankab=rankab~comparatorletto_sequence?order?keys_greater_or_equal_to?keys_less_or_equal_tot=to_sequence~comparator?order?keys_greater_or_equal_to?keys_less_or_equal_tot;;letbinary_searcht~comparehowv=binary_search~comparatort~comparehowvletbinary_search_segmentedt~segment_ofhow=binary_search_segmented~comparatort~segment_ofhow;;letbinary_search_subranget~compare~lower_bound~upper_bound=binary_search_subrange~comparatort~compare~lower_bound~upper_bound;;letkey_sett=Using_comparator.key_set_of_tree~comparatortletmap_keyst~f=map_keyst~f~comparatorletmap_keys_exnt~f=map_keys_exnt~f~comparatorletquickcheck_generatorkv=For_quickcheck.gen_tree~comparatorkvletquickcheck_observerkv=For_quickcheck.obs_treekvletquickcheck_shrinkerkv=For_quickcheck.shr_tree~comparatorkvendmoduleMake_tree_plain(Key:sigtypet[@@derivingsexp_of]includeComparator.Swithtypet:=tend)=structmoduleKey_S1=Comparator.S_to_S1(Key)includeMake_tree_S1(Key_S1)type+'vt=(Key.t,'v,Key.comparator_witness)Tree.tletsexp_of_tsexp_of_vt=sexp_of_tKey.sexp_of_tsexp_of_v[%sexp_of:_]tmoduleProvide_of_sexp(X:sigtypet[@@derivingof_sexp]endwithtypet:=Key.t)=structlett_of_sexpv_of_sexpsexp=t_of_sexpX.t_of_sexpv_of_sexpsexpendendmoduleMake_tree(Key:sigtypet[@@derivingsexp]includeComparator.Swithtypet:=tend)=structincludeMake_tree_plain(Key)includeProvide_of_sexp(Key)end(* Don't use [of_sorted_array] to avoid the allocation of an intermediate array *)letinit_for_bin_prot~len~f~comparator=letmap=Using_comparator.of_increasing_iterator_unchecked~len~f~comparatorinifinvariantsmapthenmapelse((* The invariants are broken, but we can still traverse the structure. *)matchUsing_comparator.of_iteri~iteri:(iterimap)~comparatorwith|`Okmap->map|`Duplicate_key_key->failwith"Map.bin_read_t: duplicate element in map");;modulePoly=structincludeCreators(Comparator.Poly)type('a,'b,'c)map=('a,'b,'c)ttype('k,'v)t=('k,'v,Comparator.Poly.comparator_witness)maptypecomparator_witness=Comparator.Poly.comparator_witnessincludeAccessorsletcompare_cmpvt1t2=compare_directcmpvt1t2letsexp_of_tsexp_of_ksexp_of_vt=Using_comparator.sexp_of_tsexp_of_ksexp_of_v[%sexp_of:_]t;;lett_sexp_grammark_grammarv_grammar=Sexplib.Sexp_grammar.coerce(List.Assoc.t_sexp_grammark_grammarv_grammar);;includeBin_prot.Utils.Make_iterable_binable2(structtypenonrec('a,'b)t=('a,'b)ttype('a,'b)el='a*'b[@@derivingbin_io]let_=bin_elletcaller_identity=Bin_prot.Shape.Uuid.of_string"b7d7b1a0-4992-11e6-8a32-bbb221fa025c";;letmodule_name=Some"Core.Map"letlength=lengthletitert~f=iterit~f:(fun~key~data->f(key,data))letinit~len~next=init_for_bin_prot~len~f:(fun_->next())~comparator:Comparator.Poly.comparator;;end)moduleTree=structincludeMake_tree_S1(Comparator.Poly)type('k,+'v)t=('k,'v,Comparator.Poly.comparator_witness)treetypecomparator_witness=Comparator.Poly.comparator_witnessletsexp_of_tsexp_of_ksexp_of_vt=sexp_of_tsexp_of_ksexp_of_v[%sexp_of:_]tlett_sexp_grammark_grammarv_grammar=Sexplib.Sexp_grammar.coerce(List.Assoc.t_sexp_grammark_grammarv_grammar);;endendmoduletypeKey_plain=Key_plainmoduletypeKey=KeymoduletypeKey_binable=Key_binablemoduletypeKey_hashable=Key_hashablemoduletypeKey_binable_hashable=Key_binable_hashablemoduletypeS_plain=S_plainmoduletypeS=SmoduletypeS_binable=S_binablemoduleKey_bin_io=Key_bin_iomoduleProvide_bin_io(Key:Key_bin_io.S)=Bin_prot.Utils.Make_iterable_binable1(structmoduleKey=Keytypenonrec'vt=(Key.t,'v,Key.comparator_witness)ttype'vel=Key.t*'v[@@derivingbin_io]let_=bin_elletcaller_identity=Bin_prot.Shape.Uuid.of_string"dfb300f8-4992-11e6-9c15-73a2ac6b815c";;letmodule_name=Some"Core.Map"letlength=lengthletitert~f=iterit~f:(fun~key~data->f(key,data))letinit~len~next=init_for_bin_prot~len~f:(fun_->next())~comparator:Key.comparator;;end)moduleMake_plain_using_comparator(Key:sigtypet[@@derivingsexp_of]includeComparator.Swithtypet:=tend)=structmoduleKey=KeymoduleKey_S1=Comparator.S_to_S1(Key)includeCreators(Key_S1)typekey=Key.ttype('a,'b,'c)map=('a,'b,'c)ttype'vt=(key,'v,Key.comparator_witness)mapincludeAccessorsletcomparecmpvt1t2=compare_directcmpvt1t2letsexp_of_tsexp_of_vt=Using_comparator.sexp_of_tKey.sexp_of_tsexp_of_v[%sexp_of:_]t;;moduleProvide_of_sexp(Key:sigtypet[@@derivingof_sexp]endwithtypet:=Key.t)=structlett_of_sexpv_of_sexpsexp=t_of_sexpKey.t_of_sexpv_of_sexpsexpendmoduleProvide_hash(Key':Hasher.Swithtypet:=Key.t)=structlethash_fold_t(typea)hash_fold_datastate(t:at)=Using_comparator.hash_fold_directKey'.hash_fold_thash_fold_datastatet;;endmoduleProvide_bin_io(Key':sigtypet[@@derivingbin_io]endwithtypet:=Key.t)=Provide_bin_io(structincludeKeyincludeKey'end)endmoduleMake_plain(Key:Key_plain)=Make_plain_using_comparator(structincludeKeyincludeComparator.Make(Key)end)moduleMake_using_comparator(Key_sexp:sigtypet[@@derivingsexp]includeComparator.Swithtypet:=tend)=structincludeMake_plain_using_comparator(Key_sexp)moduleKey=Key_sexpincludeProvide_of_sexp(Key)module_=structincludeTreeincludeProvide_of_sexp(Key)endendmoduleMake(Key:Key)=Make_using_comparator(structincludeKeyincludeComparator.Make(Key)end)moduleMake_binable_using_comparator(Key_bin_sexp:sigtypet[@@derivingbin_io,sexp]includeComparator.Swithtypet:=tend)=structincludeMake_using_comparator(Key_bin_sexp)moduleKey=Key_bin_sexpincludeProvide_bin_io(Key)endmoduleMake_binable(Key:Key_binable)=Make_binable_using_comparator(structincludeKeyincludeComparator.Make(Key)end)moduleFor_deriving=structmoduleM=Map.Mletbin_shape_m__t(typetc)(m:(t,c)Key_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_shape_t;;letbin_size_m__t(typetc)(m:(t,c)Key_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_size_t;;letbin_write_m__t(typetc)(m:(t,c)Key_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_write_t;;letbin_read_m__t(typetc)(m:(t,c)Key_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_read_t;;let__bin_read_m__t__(typetc)(m:(t,c)Key_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.__bin_read_t__;;moduletypeQuickcheck_generator_m=sigincludeComparator.Svalquickcheck_generator:tQuickcheck.Generator.tendmoduletypeQuickcheck_observer_m=sigincludeComparator.Svalquickcheck_observer:tQuickcheck.Observer.tendmoduletypeQuickcheck_shrinker_m=sigincludeComparator.Svalquickcheck_shrinker:tQuickcheck.Shrinker.tendletquickcheck_generator_m__t(typekcmp)(moduleKey:Quickcheck_generator_mwithtypet=kandtypecomparator_witness=cmp)v_generator=quickcheck_generator(moduleKey)Key.quickcheck_generatorv_generator;;letquickcheck_observer_m__t(typekcmp)(moduleKey:Quickcheck_observer_mwithtypet=kandtypecomparator_witness=cmp)v_observer=quickcheck_observerKey.quickcheck_observerv_observer;;letquickcheck_shrinker_m__t(typekcmp)(moduleKey:Quickcheck_shrinker_mwithtypet=kandtypecomparator_witness=cmp)v_shrinker=quickcheck_shrinkerKey.quickcheck_shrinkerv_shrinker;;moduletypeFor_deriving=Map.For_derivinginclude(Map:For_derivingwithtype('a,'b,'c)t:=('a,'b,'c)t)endincludeFor_derivingmoduleTree=structincludeTreeletvalidate~nameft=Validate.alist~namef(to_alistt)letvalidatei~nameft=Validate.list~name:(Fn.composenamefst)f(to_alistt)letof_hashtbl_exn=Using_comparator.tree_of_hashtbl_exnletkey_set=Using_comparator.key_set_of_treeletof_key_set=Using_comparator.tree_of_key_setletquickcheck_generator~comparatorkv=For_quickcheck.gen_tree~comparatorkvletquickcheck_observerkv=For_quickcheck.obs_treekvletquickcheck_shrinker~comparatorkv=For_quickcheck.shr_tree~comparatorkvendmoduleStable=structmoduleV1=structtypenonrec('k,'v,'cmp)t=('k,'v,'cmp)tmoduletypeS=sigtypekeytypecomparator_witnesstypenonrec'at=(key,'a,comparator_witness)tincludeStable_module_types.S1withtype'at:='atendincludeFor_derivingmoduleMake(Key:Stable_module_types.S0)=Make_binable_using_comparator(Key)endmoduleSymmetric_diff_element=Symmetric_diff_element.Stableend