我有一个算法图表类型
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 = (* ... *)
我该如何正确地做到这一点?
答案 0 :(得分:2)
我很确定你应该module Gr = Graph.Graph (VoidLabels)
。