Ocaml 模块选项的语法

Ocaml 模块选项的语法,ocaml,Ocaml,我正在尝试创建具有可选映射的类型: module CharMap = Map.Make(Char) type trie = bool * CharMap.t option 但这会导致语法错误: Error: The type constructor CharMap.t expects 1 argument(s), but is here applied to 0 argument(s) 我做错了什么?CharMap.t是从char到'a的映射,所以实际上它的类型是'a Char

我正在尝试创建具有可选映射的类型:

module CharMap = Map.Make(Char)
type trie = bool * CharMap.t option
但这会导致语法错误:

Error: The type constructor CharMap.t expects 1 argument(s),
       but is here applied to 0 argument(s)

我做错了什么?

CharMap.t
是从
char
'a
的映射,所以实际上它的类型是
'a CharMap.t
,所以您忘了指定多态参数。所以你应该写:

type 'a trie = bool * 'a CharMap.t option
如果您希望地图是单态的(例如
char->int
),您可以编写:

type trie = bool * int CharMap.t option

有没有办法让我指定“a”必须是什么?