【发布时间】:2018-02-27 01:00:38
【问题描述】:
在this question 之后,我创建了一个定义具体Map 类型的文件(以及模块):
/* Scores.re */
module StringMap = Map.Make({
type t = string;
let compare = compare
});
type scores = StringMap.t(int);
现在,我想在另一个文件中使用该类型:
/* Demo.re */
let currentScores = Scores.scores.empty;
Js.log(currentScores);
但是,这给了我错误:
The value scores can't be found in Scores
如果我添加一个常量(例如let n = 123; 和Js.log(Scores.n);),那么它就可以工作。
我在这里错过了什么?
【问题讨论】:
-
原来
empty生活在StringMap,而不是scores。我觉得这很令人惊讶。确定要创建Map实例,必须知道键类型?
标签: dictionary module ocaml reason reasonml