相关疑难解决方法(0)

如何让 ocaml 相信两个函子实例化是相等的

假设我有许多模块,它们都使用一种模块类型进行参数化,并且彼此之间也具有依赖关系:

module type AT = sig  
end

module B(A: AT) = struct
  module Hash = struct
    type t = int
    let equal b1 b2 = b1 = b2
    let hash b = b
  end
end

module C(A: AT) = struct
  module B = B(A)
  module Hashtbl = Hashtbl.Make(B.Hash)

  let make () = Hashtbl.create 16
end

module D(A: AT) = struct
  module B = B(A)
  module Hashtbl = Hashtbl.Make(B.Hash)

  let use ht =
    Hashtbl.clear ht
end

module E(A: AT) = struct …
Run Code Online (Sandbox Code Playgroud)

ocaml

2
推荐指数
1
解决办法
174
查看次数

标签 统计

ocaml ×1