123456789101112131415161718192021222324252627282930313233343536373839404142434445464748openOrderedmoduleId=structmoduletypeS=sigtypetincludeStringable.Swithtypet:=tincludeComparablewithtypet:=tendmoduleMake(T:S)=structincludeTendendmoduleNumId=structmoduletypeNumType=sigtypetincludeId.Swithtypet:=tvalzero:tvalone:tvaladd:t->t->tvalof_string_opt:string->toptionendmoduletypeS=sigtypetincludeNumTypewithtypet:=tvalnext_id:unit->tendmoduleMake(T:NumType)=structincludeTtypestate={mutablecount:T.t}letstate={count=T.zero}letnext_id()=letr=state.countin(** roll-over to negatives and eventually back to zero*)state.count<-T.addstate.countT.one;rendend