OCaml でレコード型を強制できないのはなぜですか? のような基本型は正常にint
動作します。
M
以下は、 moduleに含める基本モジュールを構築する例ですA
。M.t
は で省略されたタイプですA
。M.t
ある限りint
、私はできますA.t' :> M.t
。に変更すると{i : int}
、コンパイラはサブタイプではないと言います。これには非常に具体的な理由があると思いますか?
module M = struct
type t = {i : int}
let make () = {i = 10}
end
module A : sig
include module type of M
type t' = private t
val make : unit -> t'
end = struct
include M
type t' = t
end
トップレベルで:
(A.make() :> M.t);;
Error: Type A.t' is not a subtype of M.t