我有以下情况:
module type M = sig type s = ... end
module Make(P: Something) : (M with type s = P.t) = struct
type s = P.t
...
end
这适用于生成模块 M
使用类型模块的特定实现的类型 Something
在他们的实施中。
现在假设我有另一个模块定义为
module type AU = sig
val feed : float -> unitv
val nth : int -> (float -> float)
val reset : unit -> unit
end
有各种实现
module SUAlg : AU = struct ... end
module MLAlg : AU = struct ... end
module ACEAlg : AU = struct ... end
问题的关键在于 M
模块现在应该在两个方面进行参数化:a Something
模块和 AU
模块,这样就像
module Make(P: Something) : (M with type s = P.t) = struct
type s = P.t
module Alg = MLAlg (* just an example *)
...
end
但我希望有一个通用仿函数给出一个 Something
给了一个 AU
它生成一个模块,两个东西都具体化。有没有办法轻松获得?
仿函数语法很奇怪,我还是新手,我不知道我问的问题是否可以用简单的方法解决。
提前致谢