(***********************************************************************) (* v * The Coq Proof Assistant / The Coq Development Team *) (* let n = !count in incr count; n type t = Obj.t Util.Intmap.t module Field = struct type 'a field = { set : 'a -> t -> t ; get : t -> 'a option ; remove : t -> t } type 'a t = 'a field end open Field let empty = Util.Intmap.empty let field () = let fid = next () in let set a s = Util.Intmap.add fid (Obj.repr a) s in let get s = try Some (Obj.obj (Util.Intmap.find fid s)) with _ -> None in let remove s = Util.Intmap.remove fid s in { set = set ; get = get ; remove = remove }