将仿函数保存在单独的文件中

Keeping a functor in a separate file

我有一个函数化的图形类型

module type GRAPH_LABELS =
    sig
        type label
    end

module type GRAPH =
    sig
        type label
        type graph
        val init : int -> graph
        val size : graph -> int
        val insert_directed_edge : graph -> int -> int -> label -> unit
        val insert_edge : graph -> int -> int -> label -> unit
        val neighbours : graph -> int -> (int*label) list
    end

module Graph = functor (L : GRAPH_LABELS) ->
    struct
        (* implementation which matches GRAPH *)
    end

我想将它保存在一个单独的文件中。我把所有东西都放进了graph.ml。当我用仿函数创建模块时

module VoidLabels = struct type label = unit end
module Gr = Graph (VoidLabels)

我收到一个错误:

This module is not a functor; it has type
       sig
         module type GRAPH_LABELS = sig type label end
         module type GRAPH = (* ... *)

我该如何正确操作?

我很确定你应该 module Gr = Graph.Graph (VoidLabels)