123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105open!Core(** [Var_id] is a faster ['a Type_equal.Id.t] meant to store mappings of
['a Var_id.t -> 'a Data.t]
in a way such that each ['a key * 'a data] have the same ['a].
We are using our own version of this univ map mechanism for speed / memory
optimization purposes. *)moduletypeS=sig(** An identifier for something parameterized by ['a]. More efficient than
[Type_equal.Id]. *)type'atvalcreate:unit->_tvalsame:'at->'bt->boolvalsame_witness:'at->'bt->('a,'b)Type_equal.toptionvalsame_witness_exn:'at->'bt->('a,'b)Type_equal.tmodulePacked:sigtypet_gadt=T:'at->t_gadttypet[@@derivingcompare,equal,hash,sexp]includeComparable.Swithtypet:=tmoduleTable:Hashtbl.S_plainwithtypekey=tvalreveal:t->t_gadtendvalpack:'at->Packed.tmoduleSet:sigtype'aid:='at(** A type for containing a set of [Id.t]. Typically used to track free variables
inside a computation *)typet(** the empty set *)valempty:t(** a singleton set *)valsingleton:_id->t(** returns [true] if the set contains no elements *)valis_empty:t->boolvallength:t->int(** Adds a type-id to the set. Nothing happens if the set already contains the item. *)valadd:t->_id->t(** Removes a type-id from the set. Nothing happens if the set doesn't already contain
it *)valremove:t->_id->t(** computes the union of two sets *)valunion:t->t->t(** Folds over the elements in the set *)valfold:t->init:'acc->f:('acc->Packed.t->'acc)->'acc(** maps over the set and sticks the return values in a list *)valmap_to_list:t->f:(Packed.t->'a)->'alist(** iterates over the elements in the set *)valiter:t->f:(Packed.t->unit)->unitendendmoduletypeS_map=sigtypetmoduleId:SmoduleData:T1valempty:tvalsingleton:'aId.t->'aData.t->tvaladd_exn:t->key:'aId.t->data:'aData.t->tvaladd_overwriting:t->key:'aId.t->data:'aData.t->tvalfind:t->'aId.t->'aData.toptionvalfind_exn:t->'aId.t->'aData.tvalremove:t->'aId.t->ttypecombine={combine:'a.key:'aId.t->'aData.t->'aData.t->'aData.t}type'accfolder={f:'a.'aId.t->'aData.t->'acc->'acc}type'bmapper={f:'a.'aId.t->'aData.t->'b}valmerge:t->t->combine->tvalfold:t->init:'acc->'accfolder->'accvalmap_to_list:t->'bmapper->'blistendmoduletypeVar_id=sigmoduletypeS=SmoduletypeS_map=S_mapincludeSmoduleMap:sigmoduleMake(Data:T1):S_mapwithtype'aId.t='atandmoduleData=Dataendend