| 1 |
(* $Id: recursive.mli,v 1.1 2002/10/10 09:11:23 cvscast Exp $ *)
|
| 2 |
|
| 3 |
exception NotEqual
|
| 4 |
exception Incomplete
|
| 5 |
|
| 6 |
module type S =
|
| 7 |
sig
|
| 8 |
type 'a t
|
| 9 |
val map: ('a -> 'b) -> ('a t -> 'b t)
|
| 10 |
|
| 11 |
val equal: ('a -> 'a -> unit) -> ('a t -> 'a t -> unit)
|
| 12 |
(* equal checks that two terms are equal and raises NotEqual otherwise;
|
| 13 |
the first argument must be called to check equality of subterms *)
|
| 14 |
|
| 15 |
val iter: ('a -> unit) -> ('a t -> unit)
|
| 16 |
(* a valid definition is often:
|
| 17 |
let iter f a = ignore (map f a) *)
|
| 18 |
|
| 19 |
val hash: ('a -> int) -> ('a t -> int)
|
| 20 |
(* [hash] should behave correctly w.r.t [map], that is:
|
| 21 |
hash h (map f a) == hash (h \circ f) a
|
| 22 |
|
| 23 |
A valid definition is often:
|
| 24 |
let hash h a = Hashtbl.hash (map h a)
|
| 25 |
*)
|
| 26 |
|
| 27 |
val deep: int
|
| 28 |
(* specify the deepness of hashing; use a value large enough to
|
| 29 |
discriminate between most non-equivalent graphs;
|
| 30 |
deep = 3 or 4 may often be adequate. *)
|
| 31 |
end
|
| 32 |
|
| 33 |
module Make(X : S) :
|
| 34 |
sig
|
| 35 |
type node
|
| 36 |
type descr = node X.t
|
| 37 |
|
| 38 |
val make: unit -> node
|
| 39 |
val define: node -> descr -> unit
|
| 40 |
|
| 41 |
val internalize: node -> node
|
| 42 |
val internalize_descr: descr -> descr
|
| 43 |
|
| 44 |
val id: node -> int
|
| 45 |
val descr: node -> descr
|
| 46 |
end
|
| 47 |
|