Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ocaml 将函子保存在单独的文件中_Ocaml_Functor - Fatal编程技术网

Ocaml 将函子保存在单独的文件中

Ocaml 将函子保存在单独的文件中,ocaml,functor,Ocaml,Functor,我有一个函数化的图形类型 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 : gra

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

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 = (* ... *)

我应该如何正确地执行它?

我很确定您应该拥有
模块Gr=Graph.Graph(VoidLabels)
以及我应该如何修改源代码以使我的呼叫合法?在文件开头添加
open Graph
。不能将函子作为顶级名称,因此没有其他方法。