原因机器学习
module type T = {
type t('a); // Does not work
type b; // Works
};
module A: T = {
type t('a) = {.. b: bool} as 'a;
type b = bool;
};
module B: T = {
type t('a) = {.. c: int} as 'a;
type b = int;
};
奥卡姆
module type T = sig
type 'a t /* Doesn't work */
type b /* Works */
end
module A : T = struct type 'a t = < b :bool ;.. > as 'a
type b = bool end
module B : T = struct type 'a t = < c :int ;.. > as 'a
type b = int end
如何定义模块类型 A t('a) 使其抽象但与实现中的开放多态对象类型兼容?