我已经定义了一个A由几个函子使用的接口,特别是MyFunctor:
module type A = sig
val basic_func: ...
val complex_func: ...
end
module MyFunctor :
functor (SomeA : A) ->
struct
...
let complex_impl params =
...
(* Here I call 'basic_func' from SomeA *)
SomeA.basic_func ...
...
end
Run Code Online (Sandbox Code Playgroud)
现在我想定义一个B实现接口的模块A。特别是, 的实现complex_func应该使用basic_functhrough complex_implin MyFunctor:
module B = struct
let basic_func = ...
let complex_func ... =
let module Impl = MyFunctor(B) in
Impl.complex_impl ...
end
Run Code Online (Sandbox Code Playgroud)
但是,此代码无法编译,因为 …
ocaml ×1