recursive.mli 1.16 KB
Newer Older
1
(* $Id: recursive.mli,v 1.1 2002/10/10 09:11:23 cvscast Exp $ *)
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

exception NotEqual
exception Incomplete

module type S = 
sig
  type 'a t
  val map: ('a -> 'b) -> ('a t -> 'b t)

  val equal: ('a -> 'a -> unit) -> ('a t -> 'a t -> unit)
      (* equal checks that two terms are equal and raises NotEqual otherwise;
	 the first argument must be called to check equality of subterms *)

  val iter: ('a -> unit) -> ('a t -> unit)
      (* a valid definition is often: 
	 let iter f a = ignore (map f a) *)
      
  val hash: ('a -> int) -> ('a t -> int)
      (* [hash] should behave correctly w.r.t [map], that is:
	 hash h (map f a) == hash (h \circ f) a
	 
	 A valid definition is often:
	 let hash h a = Hashtbl.hash (map h a)
      *)
      
  val deep: int
      (* specify the deepness of hashing; use a value large enough to
	 discriminate between most non-equivalent graphs;
	 deep = 3 or 4 may often be adequate. *)
end

module Make(X : S) : 
sig 
  type node
  type descr = node X.t

  val make: unit -> node
  val define: node -> descr -> unit

  val internalize: node -> node
  val internalize_descr: descr -> descr

  val id: node -> int
  val descr: node -> descr
end