fork download
  1. module type PT = sig end
  2. module P = struct end
  3.  
  4. let () =
  5. Random.self_init ()
  6.  
  7. module OrigHashtbl = Hashtbl
  8. module Hashtbl = struct
  9. module Make(Hash: OrigHashtbl.HashedType) = struct
  10. let random = Random.int 1000000
  11.  
  12. type 'a t = { t_list: (Hash.t * 'a) list }
  13.  
  14. let create _ =
  15. Format.printf "Random %d@." random;
  16. { t_list = [] }
  17.  
  18. let mem ht v =
  19. Format.printf "Random %d@." random;
  20. List.mem_assoc v ht.t_list
  21. end
  22. end
  23.  
  24. module Hash = struct
  25. type t = int
  26. let equal x1 x2 = x1 = x2
  27. let hash x = x
  28. end
  29.  
  30. module Wrap(P: PT) = struct
  31. module H = Hashtbl.Make(Hash)
  32. end
  33.  
  34. module Wrap1 = Wrap(P)
  35. module Wrap2 = Wrap(P)
  36. module H1 = Wrap1.H
  37. module H2 = Wrap2.H
  38.  
  39. let () =
  40. let ht = H1.create 16 in
  41. Format.printf "%b@." (H2.mem ht 0)
Success #stdin #stdout 0s 4268KB
stdin
Standard input is empty
stdout
Random 961688
Random 30424
false