0

我正在尝试将 Irmin 与 MirageOS 一起使用,并且我正在努力处理所有这些模块。我查看了 Canopy 的来源,试图弄清楚应该如何使用 Irmin,我有这个:

let start console clock resolver conduit =
  let (module Context) = Irmin_mirage.context (resolver, conduit) in
  let module Mirage_git_memory = Irmin_mirage.Git.Mem.KV(Context)(Git.Inflate.M) in
  let module Store = Mirage_git_memory(Irmin.Contents.String) in
  [...]

从开始功能,我可以很好地使用 Store,设置并阅读 repo .. 我如何传递 Store ?由于所有这些类型都依赖于 start 的参数,我不能(或不知道如何)在其他任何地方定义这些模块,并且我在其他任何地方传递或定义 Store 的所有尝试都失败了,因为构造函数会逃避它们范围。我确实设法创建了自己的 store.ml 文件(就像在 Canopy 中一样),但它只是将问题转移到一个新模块,我仍然不知道如何传递它。

在树冠中,他们似乎只从 start 函数中使用 Store 模块,这对他们来说很好,但不是我想做的。

我正在尝试使用 Irmin,但我认为这不是 Irmin 问题,我可能只是对模块系统在 ocaml 中的工作方式非常错误。当我尝试将它传递给另一个函数或模块时,我最终会遇到错误,例如

The signature for this packaged module couldn't be inferred.

这似乎合乎逻辑,但我不知道如何解决这个问题。

谢谢

4

1 回答 1

2

对于 OCaml 编译器来说,一流的模块(如let (module Context))有点难以处理,特别是它通常无法自行推断它们的类型。

解决方案是添加手动注释:

let (module Context : Irmin_mirage.CONTEXT) = Irmin_mirage.context (resolver, conduit) in
...
于 2018-08-07T07:49:34.503 回答