【问题标题】:OCaml Mascot can't find modules from .mli filesOCaml Mascot 无法从 .mli 文件中找到模块
【发布时间】:2012-10-26 19:27:29
【问题描述】:

给定以下源文件:

(* /tmp/src/A.mli *)
val f : B.t -> B.t

(* /tmp/src/A.ml *)
let f (x : B.t) = x

(* /tmp/src/B.mli *)
type t

(* /tmp/src/B.ml *)
type t = int

我尝试运行 mascot 代码检查器,但它无法绑定从 .mli 文件引用的模块,尽管有 -I 标志。它可以很好地解析来自.ml 文件的绑定。

$ mascot.native -config mascot.cfg -I /tmp/src /tmp/src/{A,B}.{ml,mli} -html /tmp/out
File "/tmp/src/A.mli", line 2, characters 8-11:
Error: Unbound module B
loading configuration files...
configuring checks...
analyzing dependencies...
running checks...
reporting to "/tmp/out" with output "html"...

它可以很好地解析来自 .ml 文件的绑定。

$ mascot.native -config mascot.cfg -I /tmp/src /tmp/src/{A,B}.ml -html /tmp/out
loading configuration files...
configuring checks...
analyzing dependencies...
running checks...
reporting to "/tmp/out" with output "html"...

我在 manual 中找不到任何解释 files-to-analyze 的内容,但我相信 Mascot 应该在接口文件上运行,因为 examples 页面包含文档示例问题:

(** Module descriptoion. *)

type t
(* This one is not actually documented
   (bare comment instead of ocamldoc one). *)

当我只提供源文件时,似乎没有运行接口检查。

【问题讨论】:

    标签: ocaml


    【解决方案1】:

    我遇到了同样的问题,只有编译它的接口文件在当前目录中有B.cmi,才能让Mascot找到模块B,例如:

    cd /tmp/src
    ocamlc B.mli
    mascot.native -config mascot.cfg {A,B}.{ml,mli} -html /tmp/out.html
    

    似乎没有命令行选项告诉 Mascot 在哪里寻找.mli/.cmi 文件;如问题中所述,-I 标志对此不起作用。

    【讨论】:

    • 所以如果我使用ocamlbuild 那么我应该从_build 目录运行吉祥物?
    • 当然可以。顺便说一句,我认为这是Mascot的一个限制。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    • 2016-09-15
    • 1970-01-01
    相关资源
    最近更新 更多