123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172(******************************************************************************)(* *)(* Fix *)(* *)(* François Pottier, Inria Paris *)(* *)(* Copyright Inria. All rights reserved. This file is distributed under the *)(* terms of the GNU Library General Public License version 2, with a *)(* special exception on linking, as described in the file LICENSE. *)(* *)(******************************************************************************)openSigsmoduleMake(F:FINITE_TYPE)(M:MINIMAL_IMPERATIVE_MAPSwithtypekey=F.t)=structtypekey=M.keylettabulate(f:key->'a):key->'a=lettable=M.create()inF.foreach(funx->M.addx(fx)table);funx->tryM.findxtablewithNot_found->(* This cannot happen if [foreach] is exhaustive. *)letmsg=Printf.sprintf"\n Fix.Tabulate says: \
please check that your \"foreach\" function is \
exhaustive.\n %s\n"__LOC__inraise(Invalid_argumentmsg)endmoduleForOrderedType(F:FINITE_TYPE)(T:OrderedTypewithtypet=F.t)=Make(F)(Glue.PersistentMapsToImperativeMaps(Map.Make(T)))moduleForHashedType(F:FINITE_TYPE)(T:HashedTypewithtypet=F.t)=Make(F)(Glue.HashTablesAsImperativeMaps(T))moduleForType(F:FINITE_TYPE)=ForHashedType(F)(Glue.TrivialHashedType(F))moduleForIntSegment(K:sigvaln:intend)=structtypekey=intlettabulate(f:key->'a):key->'a=lettable=Array.initK.nfinfunx->table.(x)endmoduleForNumberedType(T:NUMBERING)=structtypekey=T.tlettabulate(f:key->'a):key->'a=lettable=Array.initT.n(funi->f(T.decodei))infunx->table.(T.encodex)end