パラメトリックタイプのモジュールに応じて関数を記述する方法を理解しようとしていますが、どこでも同様のものは見つかりません。私は可能な限り問題を減らそうとし、このダミーの例で終わった。パラメトリックローカル抽象タイプ
module type Mappable = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
let plus (type m) (module M : Mappable with type 'a t = 'a m) (xs : int m) =
M.map (fun x -> x + 1) xs
これはエラーError: Syntax error: module-expr expected
を生成します。
私が'a
を削除すると、次のエラーが発生します。
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match: type t is not included in type 'a t
They have different arities.
これを行う正しい構文は何ですか?