module type MYVERTEX = sig
include VERTEX
type edge
val out_edges : t -> edge list
end
module MyVertex = struct
type edge
type t = { label : int; out_edges : edge list }
let out_edges v = v.out_edges
...
end
module MyEdge = struct
type vertex
type t = { label : int; src : vertex; dst : vertex }
...
end
module Make_MyGraph(V : MYVERTEX with type edge = E.t)(E : EDGE with type vertex = V.t) = struct
module V = V
module E = E
...
end
The compiler found an error on "with type edge = E.t" : "Unbound type constructor E.t". I understood it, E has not been defined yet, but I want to do that any way : if I suppress "with type edge = E.t", the V.edge and E.t types are not the same (and some other functions inside Make_MyGraph won't work).
I tried things like :
module Make_MyGraph(VV : MYVERTEX)(EE : EDGE with type vertex = V.t) = struct
module E = EE
module V = VV with type edge = E.t (*ocamlc doesn't understand the with keyword here*)
...
end
or
module Make_MyEdge(E : EDGE)(V : MYVERTEX with type edge = E.t) = struct
include V
end
module Make_MyGraph(VV : MYVERTEX)(EE : EDGE with type vertex = VV.t) = struct
module E = EE
module V = Make_MyEdge(E)(VV) (*ocamlc doesn't accepte VV,
Modules do not match:
sig type t = VV.t type label = VV.label type edge = VV.edge end
is not included in
sig type t type label type edge = E.t end
*)
...
end
--
Damien Bobillot
Test.ml file :
===================
module type VERTEX = sig
type t
type label
end
module type EDGE = sig
type t
type label
type vertex
end
module type MYVERTEX = sig
include VERTEX
type edge
end
module MyVertex = struct
type edge
type t = { label : int; out_edges : edge list }
end
module MyEdge = struct
type vertex
type t = { label : int; src : vertex; dst : vertex }
end
module Make_MyGraph(V : MYVERTEX with type edge = E.t)(E : EDGE with type vertex = V.t) = struct
module V = V
module E = E
end
(*module Make_MyGraph(VV : MYVERTEX)(EE : EDGE with type vertex = V.t) = struct
module E = EE
module V = VV with type edge = E.t
end*)
(*module Make_MyEdge(E : EDGE)(V : MYVERTEX with type edge = E.t) = struct
include V
end
module Make_MyGraph(VV : MYVERTEX)(EE : EDGE with type vertex = VV.t) = struct
module E = EE
module V = Make_MyEdge(E)(VV)
end*)
===========