I have a type problem in the following code (some simple implementation of the module functional graph). Types seem to live their own lives.
I have type t = NotaEdge | Edge of int*v*v, implemented in the Edge module, this type in the Graph module becomes type edge = E.t. Everything seems fine to me, except for the fact that I cannot match it with a template, because the Edge constructor is still undefined in the Graph module.
Exactly in the su function, when I try to combine with Edge (l, n, m): #Error: Unbound constructor Edge
Hope someone can introduce it beautifully, thanks in advance :)
module Vertex : Vertex with type label = int =
struct
type t = NotaNode | Node of int
type label = int
exception No of string
...
module Edge : Edge with type label = int and type v = Vertex.t =
struct
type v = Vertex.t
type t = NotaEdge | Edge of int*v*v
type label = int
exception No of string
...
module Graph (E : Edge) (V : Vertex) : Graph with type vertex = V.t and type edge = E.t =
struct
type vertex = V.t
type edge = E.t
type t = E.t list* V.t list
let empty = ([],[])
let rec suc (x:edge list) (v1:vertex) =
match x with
y::ys -> (match y with
(*Error
| _ -> [])
|[] -> []
let succ (t1:t) (v1:vertex) =
match t1 with
(x,_) -> suc x v1
...
mechu source
share