Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /smlnj-lib/trunk/HashCons/hash-cons-sig.sml
ViewVC logotype

Annotation of /smlnj-lib/trunk/HashCons/hash-cons-sig.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4187 - (view) (download)

1 : jhr 967 (* hash-cons-sig.sml
2 :     *
3 : jhr 3580 * COPYRIGHT (c) 2011 The Fellowship of SML/NJ (http://www.smlnj.org)
4 :     * All rights reserved.
5 : jhr 4187 *
6 :     * TODO: better support for nodes that mix lists and non-lists as args.
7 :     * (perhaps a hashed-cons list rep)?
8 : jhr 967 *)
9 :    
10 :     signature HASH_CONS =
11 :     sig
12 :    
13 :     (* hash table for consing *)
14 :     type 'a tbl
15 : jhr 4187
16 :     (* create a new hash-cons table using the given equality function *)
17 : jhr 967 val new : {eq : 'a * 'a -> bool} -> 'a tbl
18 : jhr 4187
19 :     (* clear a table of all elements *)
20 : jhr 967 val clear : 'a tbl -> unit
21 :    
22 : jhr 4187 (* a hashed-cons object *)
23 :     type 'a obj = {
24 :     nd : 'a, (* the underlying representation *)
25 :     tag : word, (* a tag that is unique for the object (for the object's table) *)
26 :     hash : word (* a hash of the object (used to index the table) *)
27 :     }
28 : jhr 967
29 : jhr 4187 (* projections *)
30 : jhr 967 val node : 'a obj -> 'a
31 :     val tag : 'a obj -> word
32 :    
33 : jhr 4187 (* comparisons *)
34 : jhr 967 val same : ('a obj * 'a obj) -> bool
35 :     val compare : ('a obj * 'a obj) -> order
36 :    
37 : jhr 4187 (* constructors for nodes formed from tuples of children *)
38 : jhr 967 val cons0 : 'a tbl -> (word * 'a) -> 'a obj
39 :     val cons1 : 'a tbl -> (word * ('b obj -> 'a))
40 :     -> 'b obj -> 'a obj
41 :     val cons2 : 'a tbl -> (word * ('b obj * 'c obj -> 'a))
42 :     -> 'b obj * 'c obj -> 'a obj
43 :     val cons3 : 'a tbl -> (word * ('b obj * 'c obj * 'd obj -> 'a))
44 :     -> 'b obj * 'c obj * 'd obj -> 'a obj
45 :     val cons4 : 'a tbl -> (word * ('b obj * 'c obj * 'd obj * 'e obj -> 'a))
46 :     -> 'b obj * 'c obj * 'd obj * 'e obj -> 'a obj
47 :     val cons5 : 'a tbl -> (word * ('b obj * 'c obj * 'd obj * 'e obj * 'f obj -> 'a))
48 :     -> 'b obj * 'c obj * 'd obj * 'e obj * 'f obj -> 'a obj
49 : jhr 1193
50 : jhr 4187 (* constructor for nodes formed from a list of children *)
51 : jhr 967 val consList : 'a tbl -> (word * ('b obj list -> 'a)) -> 'b obj list -> 'a obj
52 :    
53 : jhr 4187 (* constructors for nodes formed from records of children; the arguments include
54 :     * a node constructor from a tuple of children and a projection from the record
55 :     * type to a tuple type.
56 :     *)
57 : jhr 1193 val consR1 : 'a tbl -> (word * ('b obj -> 'a) * ('r -> 'b obj))
58 :     -> 'r -> 'a obj
59 :     val consR2 : 'a tbl
60 :     -> (word * ('b obj * 'c obj -> 'a) * ('r -> 'b obj * 'c obj))
61 :     -> 'r -> 'a obj
62 :     val consR3 : 'a tbl
63 :     -> (word * ('b obj * 'c obj * 'd obj -> 'a)
64 :     * ('r -> 'b obj * 'c obj * 'd obj))
65 :     -> 'r -> 'a obj
66 :     val consR4 : 'a tbl
67 :     -> (word * ('b obj * 'c obj * 'd obj * 'e obj -> 'a)
68 :     * ('r -> 'b obj * 'c obj * 'd obj * 'e obj))
69 :     -> 'r -> 'a obj
70 :     val consR5 : 'a tbl
71 :     -> (word * ('b obj * 'c obj * 'd obj * 'e obj * 'f obj -> 'a)
72 :     * ('r -> 'b obj * 'c obj * 'd obj * 'e obj * 'f obj))
73 :     -> 'r -> 'a obj
74 :    
75 : jhr 967 end
76 :    

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0