12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576(**************************************************************************)(* This file is part of the Codex semantics library *)(* (patricia-tree sub-component). *)(* *)(* *)(* Copyright (C) 2013-2026 *)(* CEA (Commissariat à l'énergie atomique et aux énergies *)(* alternatives) *)(* *)(* You can redistribute it and/or modify it under the terms of the GNU *)(* Lesser General Public License as published by the Free Software *)(* Foundation, version 2.1. *)(* *)(* It is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Lesser General Public License for more details. *)(* *)(* See the GNU Lesser General Public License version 2.1 *)(* for more details (enclosed in the file LICENSE). *)(* *)(**************************************************************************)openSignatures(** {1 Keys and values} *)moduleHomogeneousValue=structtype('a,'map)t='mapendmoduleWrappedHomogeneousValue=structtype('a,'map)t=('a,'map)sndendmoduleHeterogeneousKeyFromKey(Key:KEY):HETEROGENEOUS_KEYwithtype'at=Key.t=structtype_t=Key.t(** The type-safe way to do it would be to define this type, to
guarantee that 'a is always bound to the same type, and Eq is
safe. But this requires a lot of conversion code, and identity
functions that may not be well detected. [polyeq] is unsafe in
that it allows arbitrary conversion of t1 by t2 in t1 t, but
this unsafety is not exported, and I don't think we can do
something wrong using it. *)(* type 'a t = K: Key.t -> unit t [@@unboxed] *)letpolyeq:typeab.at->bt->(a,b)cmp=funab->matcha,bwith|a,bwhen(Key.to_inta)==(Key.to_intb)->Obj.magicEq|_->Diffletto_int=Key.to_intendmoduleValue:VALUEwithtype'at='a=structtype'at='aendmoduleHashedValue:HASHED_VALUEwithtype'at='a=structincludeValuelethashx=Hashtbl.hashxletpolyeq:typeab.a->b->bool=funab->a==Obj.magicbendmoduleHeterogeneousHashedValue:HETEROGENEOUS_HASHED_VALUEwithtype('k,'m)t='m=structincludeHomogeneousValuelethashx=Hashtbl.hashxletpolyeq:typeab.a->b->bool=funab->a==Obj.magicbendmoduleHeterogeneousHashedValueFromHashedValue(Value:HASHED_VALUE):HETEROGENEOUS_HASHED_VALUEwithtype('a,'map)t=('a,'mapValue.t)snd=structtype('a,'map)t=('a,'mapValue.t)sndlethash(Sndx)=Value.hashxletpolyeq(Snda)(Sndb)=Value.polyeqabend