module type Extensible = sig type t type 'a constructor val create : unit -> 'a constructor val inject : 'a constructor -> 'a -> t val matches : t -> 'a constructor -> ('a -> 'b) -> (t -> 'b) -> 'b (* val outo : 'a constructor -> t -> 'a option val oute : 'a constructor -> t -> 'a val is : 'a constructor -> t -> bool *) end;; module Make (X : sig end) : Extensible = struct type t = Obj.t type 'a constructor = unit ref let create () = ref () let inject c v = Obj.repr (c,v) let matches x c f g = let xc, xv = Obj.magic x in if xc == c then f xv else g x (* let outo c x = out c x (fun z -> Some z) (fun z -> None) let oute c x = out c x (fun z -> z) (fun x -> raise (Invalid_argument "oute")) let is c x = out c x (fun _ -> true) (fun _ -> false) *) end ;;