123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538open!ImportmoduleList=List0openSet_intfmoduleMerge_to_sequence_element=Merge_to_sequence_elementmoduleNamed=NamedmoduletypeElt_plain=Elt_plainmoduletypeElt=EltmoduletypeElt_binable=Elt_binableletto_comparator(typekcmp)((moduleM):(k,cmp)Set.comparator)=M.comparatorletof_comparator(typekcmp)comparator:(k,cmp)Set.comparator=(modulestructtypet=ktypecomparator_witness=cmpletcomparator=comparatorend);;moduleFor_quickcheck=structletquickcheck_generator~comparatorelt_gen=Base_quickcheck.Generator.set_t_m(of_comparatorcomparator)elt_gen;;letgen_tree~comparatorelt_gen=Base_quickcheck.Generator.set_tree_using_comparator~comparatorelt_gen;;letquickcheck_observerelt_obs=Base_quickcheck.Observer.set_telt_obsletobs_treeelt_obs=Base_quickcheck.Observer.set_treeelt_obsletquickcheck_shrinkerelt_shr=Base_quickcheck.Shrinker.set_telt_shrletshr_tree~comparatorelt_shr=Base_quickcheck.Shrinker.set_tree_using_comparator~comparatorelt_shr;;endletquickcheck_generatormelt_gen=For_quickcheck.quickcheck_generator~comparator:(to_comparatorm)elt_gen;;letquickcheck_observer=For_quickcheck.quickcheck_observerletquickcheck_shrinker=For_quickcheck.quickcheck_shrinkermoduleTree=structincludeTreeletto_map~comparatort=Map.of_key_set(Set.Using_comparator.of_treet~comparator)letof_map_keysm=Set.Using_comparator.to_tree(Map.key_setm)letof_hash_set~comparatorhset=Hash_set.foldhset~init:(empty~comparator)~f:(funtx->addtx~comparator);;letof_hashtbl_keys~comparatorhashtbl=Hashtbl.foldhashtbl~init:(empty~comparator)~f:(fun~key:x~data:_t->addtx~comparator);;letquickcheck_generator=For_quickcheck.gen_treeletquickcheck_observer=For_quickcheck.obs_treeletquickcheck_shrinker=For_quickcheck.shr_treeendmoduleAccessors=structinclude(Set.Using_comparator:Set.Accessors2withtype('a,'b)t:=('a,'b)Set.twithtype('a,'b)tree:=('a,'b)Tree.twithtype('a,'b)named:=('a,'b)Set.Named.t)letto_map=Map.of_key_setletquickcheck_observer=quickcheck_observerletquickcheck_shrinker=quickcheck_shrinkerendtype'acmp='atype'aelt='ainclude(structincludeSetletof_treem=Set.Using_comparator.of_tree~comparator:(to_comparatorm)letto_tree=Set.Using_comparator.to_treeletsexp_of_t=Set.Using_comparator.sexp_of_tmoduleEmpty_without_value_restriction=Set.Using_comparator.Empty_without_value_restrictionend:sigtype('a,'b)t=('a,'b)Set.t[@@derivingsexp_of]includeSet.Creators_genericwithtype('a,'b,'c)options:=('a,'b,'c)Set.With_first_class_module.twithtype('a,'b)t:=('a,'b)twithtype('a,'b)set:=('a,'b)twithtype('a,'b)tree:=('a,'b)Tree.twithtype'acmp:='acmpwithtype'aelt:='aeltincludeSet.Accessors2withtype('a,'b)t:=('a,'b)twithtype('a,'b)tree:=('a,'b)Tree.twithtype('a,'b)named:=('a,'b)Set.Named.twithmoduleNamed:=Namedend)type('k,'cmp)comparator=(moduleComparator.Swithtypet='kandtypecomparator_witness='cmp)letcompare__t1t2=compare_directt1t2moduleUsing_comparator=structinclude(Set.Using_comparator:moduletypeofstructincludeSet.Using_comparatorendwithmoduleTree:=Set.Using_comparator.Tree)includeFor_quickcheckletof_map_keys=Map.key_setletof_hash_set~comparatorhset=of_tree~comparator(Tree.of_hash_sethset~comparator);;letof_hashtbl_keys~comparatorhashtbl=of_tree~comparator(Tree.of_hashtbl_keyshashtbl~comparator);;endletto_map=Map.of_key_setletof_map_keys=Map.key_setlethash_fold_direct=Using_comparator.hash_fold_directletcomparator=Using_comparator.comparatorletof_hash_setmhset=Using_comparator.of_hash_set~comparator:(to_comparatorm)hsetletof_hashtbl_keysmhashtbl=Using_comparator.of_hashtbl_keys~comparator:(to_comparatorm)hashtbl;;moduleCreators(Elt:Comparator.S1):sigtypenonrec('a,'comparator)t_=('aElt.t,Elt.comparator_witness)ttype('a,'b)tree=('a,Elt.comparator_witness)Tree.ttype'aelt_='aElt.ttype'acmp_=Elt.comparator_witnessvalt_of_sexp:(Base.Sexp.t->'aElt.t)->Base.Sexp.t->('a,'comparator)t_includeCreators_genericwithtype('a,'b)t:=('a,'b)t_withtype('a,'b)set:=('a,'b)twithtype('a,'b)tree:=('a,'b)treewithtype'aelt:='aelt_withtype('a,'b,'c)options:=('a,'b,'c)Without_comparator.twithtype'acmp:='acmp_end=structopenUsing_comparatortypenonrec('a,'comparator)t_=('aElt.t,Elt.comparator_witness)ttype('a,'b)tree=('a,Elt.comparator_witness)Tree.ttype'aelt_='aElt.ttype'cmpcmp_=Elt.comparator_witnessletcomparator=Elt.comparatorletof_treetree=of_tree~comparatortreeletof_sorted_array_uncheckedarray=of_sorted_array_unchecked~comparatorarrayletof_increasing_iterator_unchecked~len~f=of_increasing_iterator_unchecked~comparator~len~f;;letof_sorted_arrayarray=of_sorted_array~comparatorarraymoduleM_empty=Empty_without_value_restriction(Elt)letempty=M_empty.emptyletsingletone=singleton~comparatoreletunion_listl=union_list~comparatorlletof_listl=of_list~comparatorlletof_hash_seth=of_hash_set~comparatorhletof_hashtbl_keysh=of_hashtbl_keys~comparatorhletof_arraya=of_array~comparatoraletstable_dedup_listxs=stable_dedup_list~comparatorxsletmapt~f=map~comparatort~fletfilter_mapt~f=filter_map~comparatort~flett_of_sexpa_of_sexpsexp=of_tree(Tree.t_of_sexp_directa_of_sexpsexp~comparator);;letof_map_keys=Map.key_setletquickcheck_generatorelt=quickcheck_generator~comparatoreltendmoduleMake_tree(Elt:Comparator.S1)=structletcomparator=Elt.comparatorletcompare_elt=comparator.Comparator.compareletempty=Tree.empty_without_value_restrictionletsingletone=Tree.singleton~comparatoreletinvariantst=Tree.invariantst~comparatorletlengtht=Tree.lengthtletis_emptyt=Tree.is_emptytletelementst=Tree.elementstletmin_eltt=Tree.min_elttletmin_elt_exnt=Tree.min_elt_exntletmax_eltt=Tree.max_elttletmax_elt_exnt=Tree.max_elt_exntletchooset=Tree.choosetletchoose_exnt=Tree.choose_exntletto_listt=Tree.to_listtletto_arrayt=Tree.to_arraytletitert~f=Tree.itert~fletiter2ab~f=Tree.iter2ab~f~comparatorletexistst~f=Tree.existst~fletfor_allt~f=Tree.for_allt~fletcountt~f=Tree.countt~fletsummt~f=Tree.summt~fletfindt~f=Tree.findt~fletfind_exnt~f=Tree.find_exnt~fletfind_mapt~f=Tree.find_mapt~fletfoldt~init~f=Tree.foldt~init~fletfold_untilt~init~f=Tree.fold_untilt~init~fletfold_rightt~init~f=Tree.fold_rightt~init~fletfold_resultt~init~f=Container.fold_result~fold~init~ftletmapt~f=Tree.mapt~f~comparatorletfiltert~f=Tree.filtert~f~comparatorletfilter_mapt~f=Tree.filter_mapt~f~comparatorletpartition_tft~f=Tree.partition_tft~f~comparatorletmemta=Tree.memta~comparatorletaddta=Tree.addta~comparatorletremoveta=Tree.removeta~comparatorletuniont1t2=Tree.uniont1t2~comparatorletintert1t2=Tree.intert1t2~comparatorletdifft1t2=Tree.difft1t2~comparatorletsymmetric_difft1t2=Tree.symmetric_difft1t2~comparatorletcompare_directt1t2=Tree.compare_direct~comparatort1t2letequalt1t2=Tree.equalt1t2~comparatorletis_subsett~of_=Tree.is_subsett~of_~comparatorletsubsett1t2=is_subsett1~of_:t2letof_listl=Tree.of_listl~comparatorletof_hash_seth=Tree.of_hash_seth~comparatorletof_hashtbl_keysh=Tree.of_hashtbl_keysh~comparatorletof_arraya=Tree.of_arraya~comparatorletof_sorted_array_uncheckeda=Tree.of_sorted_array_uncheckeda~comparatorletof_increasing_iterator_unchecked~len~f=Tree.of_increasing_iterator_unchecked~len~f~comparator;;letof_sorted_arraya=Tree.of_sorted_arraya~comparatorletunion_listl=Tree.union_listl~comparatorletstable_dedup_listxs=Tree.stable_dedup_listxs~comparatorletgroup_byt~equiv=Tree.group_byt~equiv~comparatorletsplitta=Tree.splitta~comparatorletnthti=Tree.nthtiletfind_index=nthletremove_indexti=Tree.remove_indexti~comparatorletto_treet=tletof_treet=tletto_sequence?order?greater_or_equal_to?less_or_equal_tot=Tree.to_sequence~comparator?order?greater_or_equal_to?less_or_equal_tot;;letbinary_searcht~comparehowv=Tree.binary_search~comparatort~comparehowvletbinary_search_segmentedt~segment_ofhow=Tree.binary_search_segmented~comparatort~segment_ofhow;;letmerge_to_sequence?order?greater_or_equal_to?less_or_equal_tott'=Tree.merge_to_sequence~comparator?order?greater_or_equal_to?less_or_equal_tott';;letof_map_keys=Tree.of_map_keysletto_mapt~f=Tree.to_map~comparatort~fmoduleNamed=structletis_subsett~of_=Tree.Named.is_subsett~of_~comparatorletequalt1t2=Tree.Named.equalt1t2~comparatorendletquickcheck_generatorelt=For_quickcheck.gen_treeelt~comparatorletquickcheck_observerelt=For_quickcheck.obs_treeeltletquickcheck_shrinkerelt=For_quickcheck.shr_treeelt~comparatorend(* Don't use [of_sorted_array] to avoid the allocation of an intermediate array *)letinit_for_bin_prot~len~f~comparator=letset=Using_comparator.of_increasing_iterator_unchecked~comparator~len~finifinvariantssetthensetelseUsing_comparator.of_tree~comparator(foldset~init:(Tree.empty~comparator)~f:(funaccelt->ifTree.memaccelt~comparatorthenfailwith"Set.bin_read_t: duplicate element in map"elseTree.addaccelt~comparator));;modulePoly=structmoduleElt=Comparator.PolyincludeCreators(Elt)typenonrec'at=('a,Elt.comparator_witness)ttype'anamed=('a,Elt.comparator_witness)Named.tincludeAccessorsletcompare_t1t2=compare_directt1t2letsexp_of_tsexp_of_kt=sexp_of_tsexp_of_k[%sexp_of:_]tincludeBin_prot.Utils.Make_iterable_binable1(structtypenonrec'at='attype'ael='a[@@derivingbin_io]let_=bin_elletcaller_identity=Bin_prot.Shape.Uuid.of_string"88bcc478-4992-11e6-a95d-ff4831acf410";;letmodule_name=Some"Core_kernel.Set"letlength=lengthletitert~f=iter~f:(funkey->fkey)tletinit~len~next=init_for_bin_prot~len~f:(fun_->next())~comparator:Comparator.Poly.comparator;;end)moduleTree=structincludeMake_tree(Comparator.Poly)type'eltt=('elt,Comparator.Poly.comparator_witness)treetype'anamed=('a,Elt.comparator_witness)Tree.Named.tletsexp_of_tsexp_of_eltt=Tree.sexp_of_tsexp_of_elt[%sexp_of:_]tlett_of_sexpelt_of_sexpsexp=Tree.t_of_sexp_directelt_of_sexpsexp~comparator:Comparator.Poly.comparator;;endendmoduletypeS_plain=S_plainmoduletypeS=SmoduletypeS_binable=S_binablemoduleElt_bin_io=Elt_bin_iomoduleProvide_bin_io(Elt:Elt_bin_io.S)=Bin_prot.Utils.Make_iterable_binable(structtypenonrect=(Elt.t,Elt.comparator_witness)ttypeel=Elt.t[@@derivingbin_io]let_=bin_elletcaller_identity=Bin_prot.Shape.Uuid.of_string"8989278e-4992-11e6-8f4a-6b89776b1e53";;letmodule_name=Some"Core_kernel.Set"letlength=lengthletitert~f=iter~f:(funkey->fkey)tletinit~len~next=init_for_bin_prot~len~f:(fun_->next())~comparator:Elt.comparator;;end)moduleMake_plain_using_comparator(Elt:sigtypet[@@derivingsexp_of]includeComparator.Swithtypet:=tend)=structmoduleElt=EltmoduleElt_S1=Comparator.S_to_S1(Elt)includeCreators(Elt_S1)type('a,'b)set=('a,'b)ttypet=(Elt.t,Elt.comparator_witness)settypenamed=(Elt.t,Elt.comparator_witness)Named.tincludeAccessorsletcomparet1t2=compare_directt1t2letsexp_of_tt=sexp_of_tElt.sexp_of_t[%sexp_of:_]tmoduleProvide_of_sexp(Elt:sigtypet[@@derivingof_sexp]endwithtypet:=Elt.t)=structlett_of_sexpsexp=t_of_sexpElt.t_of_sexpsexpendmoduleProvide_hash(Elt:Hasher.Swithtypet:=Elt.t)=structlethash_fold_tstatet=Using_comparator.hash_fold_directElt.hash_fold_tstatetlethasht=Ppx_hash_lib.Std.Hash.get_hash_value(hash_fold_t(Ppx_hash_lib.Std.Hash.create())t);;endmoduleProvide_bin_io(Elt':sigtypet[@@derivingbin_io]endwithtypet:=Elt.t)=Provide_bin_io(structincludeEltincludeElt'end)moduleTree=structincludeMake_tree(Elt_S1)typet=(Elt.t,Elt.comparator_witness)treetypenamed=(Elt.t,Elt.comparator_witness)Tree.Named.tletcomparet1t2=compare_directt1t2letsexp_of_tt=Tree.sexp_of_tElt.sexp_of_t[%sexp_of:_]tmoduleProvide_of_sexp(X:sigtypet[@@derivingof_sexp]endwithtypet:=Elt.t)=structlett_of_sexpsexp=Tree.t_of_sexp_directX.t_of_sexpsexp~comparator:Elt_S1.comparator;;endendendmoduleMake_plain(Elt:Elt_plain)=Make_plain_using_comparator(structincludeEltincludeComparator.Make(Elt)end)moduleMake_using_comparator(Elt_sexp:sigtypet[@@derivingsexp]includeComparator.Swithtypet:=tend)=structincludeMake_plain_using_comparator(Elt_sexp)moduleElt=Elt_sexpincludeProvide_of_sexp(Elt)moduleTree=structincludeTreeincludeProvide_of_sexp(Elt)endendmoduleMake(Elt:Elt)=Make_using_comparator(structincludeEltincludeComparator.Make(Elt)end)moduleMake_binable_using_comparator(Elt_bin_sexp:sigtypet[@@derivingbin_io,sexp]includeComparator.Swithtypet:=tend)=structincludeMake_using_comparator(Elt_bin_sexp)moduleElt=Elt_bin_sexpincludeProvide_bin_io(Elt)endmoduleMake_binable(Elt:Elt_binable)=Make_binable_using_comparator(structincludeEltincludeComparator.Make(Elt)end)moduleM=Set.Mletbin_shape_m__t(typetc)(m:(t,c)Elt_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_shape_t;;letbin_size_m__t(typetc)(m:(t,c)Elt_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_size_t;;letbin_write_m__t(typetc)(m:(t,c)Elt_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_write_t;;letbin_read_m__t(typetc)(m:(t,c)Elt_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.bin_read_t;;let__bin_read_m__t__(typetc)(m:(t,c)Elt_bin_io.t)=letmoduleM=Provide_bin_io((valm))inM.__bin_read_t__;;moduletypeFor_deriving=Set.For_derivinginclude(Set:For_derivingwithtype('a,'b)t:=('a,'b)t)moduleStable=structmoduleV1=structtypenonrec('a,'cmp)t=('a,'cmp)tmoduletypeS=sigtypeelttypeelt_comparator_witnesstypenonrect=(elt,elt_comparator_witness)tincludeStable_module_types.S0_without_comparatorwithtypet:=tendmoduleMake(Elt:Stable_module_types.S0)=Make_binable_using_comparator(Elt)endend