|
|
1.1 root 1: (* Copyright 1989 by AT&T Bell Laboratories *)
2: (* basics.sig *)
3:
4: (* basic datatypes *)
5:
6: signature BASICS = sig
7:
8: structure Symbol : SYMBOL
9: and Access : ACCESS
10: and IntStrMap : INTSTRMAP
11: and Stampset : STAMPSET
12: sharing Access.Symbol = Symbol (*sharing added, mt*)
13:
14: type spath (* = symbol list *)
15: type label (* = symbol *)
16: type stamp (* = int *)
17: type polysign (* = {weakness: int, eq: bool} list *)
18: type sharespec (* = {s: (spath*spath) list,
19: t: (spath*spath) list} *)
20:
21:
22: datatype bool3 = YES | NO | MAYBE
23:
24: datatype fixity = NONfix | INfix of (int*int)
25:
26: datatype conrep
27: = UNDECIDED
28: | TAGGED of int
29: | CONSTANT of int
30: | TRANSPARENT
31: | TRANSU
32: | TRANSB
33: | REF
34: | VARIABLE of Access.access (* exception constructor *)
35:
36: val infinity : int
37:
38: type tyvar (* = tvkind ref *)
39: type binder
40: type symtable
41:
42: datatype tvkind (* type variable kinds *)
43: = IBOUND of int (* inferred bound type variables -- indexed *)
44: | META of (* metavariables -- depth < infinity for lambda bound *)
45: {depth: int,
46: weakness: int,
47: eq: bool}
48: | INSTANTIATED of ty
49: | UBOUND of (* user bound type variables -- user name *)
50: {name: Symbol.symbol,
51: weakness: int,
52: eq: bool}
53:
54: and datacon (* exceptions are a special case with rep=VARIABLE() *)
55: = DATACON of
56: {name : Symbol.symbol,
57: const : bool,
58: typ : ty ref,
59: rep : conrep,
60: sign : conrep list}
61:
62: and tyckind
63: = ABStyc (* atomic and abstract types *)
64: | DEFtyc of tyfun
65: | DATAtyc of datacon list
66: | RECORDtyc of label list
67: | UNDEFtyc of Symbol.symbol list option
68:
69: and tycon
70: = TYCON of
71: {stamp : stamp,
72: arity : int,
73: eq : bool3 ref,
74: path : Symbol.symbol list,
75: kind : tyckind}
76: | INDtyc of int (* indirect tycon -- only in bindings (in sigs) *)
77: | SHRtyc of int list (* sharing indirection -- probably not used *)
78: | RELtyc of int list (* relative tycon -- only in type expressions *)
79: | NULLtyc
80:
81: and ty
82: = VARty of tyvar
83: | CONty of tycon ref * ty list
84: | FLEXRECORDty of rowty ref
85: | POLYty of {sign: {weakness:int, eq:bool} list, tyfun: tyfun}
86: | UNDEFty
87: | ERRORty
88:
89: and rowty
90: = OPEN of (label * ty) list
91: | CLOSED of ty
92:
93: and tyfun
94: = TYFUN of
95: {arity : int,
96: body : ty}
97:
98: and var
99: = VALvar of (* ordinary variables *)
100: {access : Access.access,
101: name : Symbol.symbol list,
102: typ : ty ref}
103: | OVLDvar of (* overloaded identifier *)
104: {name : Symbol.symbol,
105: options: {indicator: ty, variant: var} list ref,
106: scheme: tyfun}
107: | UNKNOWNvar of Symbol.symbol (* place holder for backpatching *)
108:
109: and strenv
110: = DIR
111: | REL of {s: Structure array, t: tycon array}
112:
113: and strkind
114: = STRkind of
115: {path : Symbol.symbol list}
116: | SIGkind of
117: {share : sharespec,
118: bindings : binding list,
119: stamps : Stampset.stampsets}
120:
121: and Structure
122: = STRstr of
123: {stamp : stamp,
124: sign : stamp,
125: table : symtable,
126: env : strenv,
127: kind : strkind}
128: | INDstr of int (* indirect substructure binding *)
129: | SHRstr of int list (* sharing indirection *)
130: | NULLstr
131:
132: and Functor
133: = FUNCTOR of
134: {paramName: Symbol.symbol,
135: param: Structure,
136: body: Structure,
137: paramVis: bool,
138: stamps: Stampset.stampsets}
139:
140: and signatureVar
141: = SIGvar of
142: {name: Symbol.symbol,
143: binding: Structure}
144:
145: and structureVar
146: = STRvar of
147: {name: Symbol.symbol list,
148: access: Access.access,
149: binding: Structure}
150:
151: and functorVar (* tentative *)
152: = FCTvar of
153: {name: Symbol.symbol,
154: access: Access.access,
155: binding: Functor}
156:
157: and fixityVar
158: = FIXvar of
159: {name: Symbol.symbol,
160: binding: fixity}
161:
162: and binding
163: = VARbind of var
164: | CONbind of datacon
165: | TYCbind of tycon ref (* patchable *)
166: | TYVbind of tyvar
167: | SIGbind of signatureVar
168: | STRbind of structureVar
169: | FCTbind of functorVar
170: | FIXbind of fixityVar
171:
172: datatype trans
173: = VALtrans of Access.access
174: (* old position, val, exn, or unthinned str *)
175: | THINtrans of Access.access * Access.lvar * trans list
176: (* old str position, substr thinning *)
177: | CONtrans of datacon (* constructor as value component *)
178: type thinning
179:
180: (* whew! *)
181:
182: val infixleft : int -> fixity
183: val infixright : int -> fixity
184:
185: val mkVALvar : Symbol.symbol * ty ref -> var
186:
187: val mkTyvar : tvkind -> tyvar
188: val mkABStyc : Symbol.symbol list * int * bool3 * Stampset.stampsets -> tycon
189: val mkDEFtyc : Symbol.symbol list * tyfun * bool3 * Stampset.stampsets -> tycon
190: val mkDATAtyc : Symbol.symbol list * int * datacon list * bool3 * Stampset.stampsets
191: -> tycon
192: val mkUNDEFtyc : Symbol.symbol * int -> tycon
193:
194: val mkSTR : Symbol.symbol list * symtable * strenv * Stampset.stampsets -> Structure
195: (* make a new "unsigned" structure *)
196:
197: end (* signature BASICS *)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.