我无法理解OCaml中模块的相等性.函数应该是应用程序(这是互联网所声称的),但这似乎有时会失败,我不能完全看到它背后的一般规则.
这是我的示例代码:
module type PT = sig end
module P = struct end
let () =
Random.self_init ()
module OrigHashtbl = Hashtbl
module Hashtbl = struct
module Make(Hash: OrigHashtbl.HashedType) = struct
let random = Random.int 1000000
type 'a t = { t_list: (Hash.t * 'a) list }
let create _ =
Format.printf "Random %d@." random;
{ t_list = [] }
let mem ht v =
Format.printf "Random %d@." random;
List.mem_assoc v ht.t_list
end
end
module Hash = struct
type t …Run Code Online (Sandbox Code Playgroud) ocaml ×1