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 Wrap(P: PT) = struct
  25. module Hash = struct
  26. type t = int
  27. let equal x1 x2 = x1 = x2
  28. let hash x = x
  29. end
  30.  
  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)
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
File "prog.ml", line 41, characters 35-37:
Error: This expression has type 'a H1.t = 'a Hashtbl.Make(Wrap1.Hash).t
       but an expression was expected of type
         'b H2.t = 'b Hashtbl.Make(Wrap2.Hash).t
stdout
Standard output is empty