模块选项的语法

时间:2012-03-19 15:51:45

标签: 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)

我做错了什么?

1 个答案:

答案 0 :(得分:8)

CharMap.t是从char'a的地图,实际上它的类型是'a Charmap.t,因此您忘记指定多态参数。所以你应该写:

type 'a trie = bool * 'a CharMap.t option

如果您希望地图是单形的(例如char -> int),您可以写下:

type trie = bool * int CharMap.t option
相关问题