frontend.icl 22.5 KB
Newer Older
1
2
implementation module frontend

3
import scanner, parse, postparse, check, type, trans, partition, convertcases, overloading, utilities, convertDynamics,
4
		convertimportedtypes, compilerSwitches, analtypes, generics1,
5
		typereify, compare_types
John van Groningen's avatar
John van Groningen committed
6

7
8
9
10
instance == FrontEndPhase where
	(==) a b
		=	equal_constructor a b

11
frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
12
13
14
15
16
	:== (Yes {
				fe_icl = {icl_mod & icl_functions=fun_defs }
			,	fe_dcls = dcl_mods
			,	fe_components = components
			,	fe_arrayInstances = array_instances
17
			},cached_dcl_macros,cached_dcl_mods,main_dcl_module_n,predef_symbols,hash_table,files,error,io,out,tcl_file,heaps
18
19
		)

20
frontEndInterface :: !(Optional (*File,{#Char},{#Char})) !FrontEndOptions !Ident !SearchPaths !{#DclModule} !*{#*{#FunDef}} !(Optional Bool) !*PredefinedSymbols !*HashTable (ModTimeFunction *Files) !*Files !*File !*File !*File !(Optional *File) !*Heaps
21
22
	-> (!Optional *FrontEndSyntaxTree,!*{#*{#FunDef}},!{#DclModule},!Int,!*PredefinedSymbols, !*HashTable, !*Files, !*File, !*File, !*File, !Optional *File, !*Heaps)
frontEndInterface opt_file_dir_time options mod_ident search_paths cached_dcl_modules cached_dcl_macros list_inferred_types predef_symbols hash_table modtimefunction files error io out tcl_file heaps
23
24
25
26
	| case opt_file_dir_time of No -> True; _ -> False
		# error = moduleCouldNotBeImportedError True mod_ident NoPos error
		= (No,{},{},0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
	# (Yes (mod_file,mod_dir,mod_time)) = opt_file_dir_time
27
	# (ok,dynamic_type_used,mod,hash_table,error,files)
28
		= wantModule mod_file mod_time cWantIclFile mod_ident NoPos options.feo_generics hash_table error files
29
	| not ok
30
		= (No,{},{},0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
John van Groningen's avatar
John van Groningen committed
31
	# cached_module_idents = [dcl_mod.dcl_name \\ dcl_mod<-:cached_dcl_modules]
32
	#! support_dynamics = case tcl_file of Yes _ -> True ; No -> False
33
	# (ok, mod, global_fun_range, mod_functions, optional_dcl_mod, modules, dcl_module_n_in_cache,hash_table, error, files)
34
		= scanModule mod cached_module_idents options.feo_generics support_dynamics hash_table error search_paths modtimefunction files
35

36
37
//	# hash_table = {hash_table & hte_entries={}}
	# hash_table = remove_icl_symbols_from_hash_table hash_table
38

39
	| not ok
40
		= (No,{},{},0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
41
  	# symbol_table = hash_table.hte_symbol_heap
John van Groningen's avatar
John van Groningen committed
42
  	#! n_cached_dcl_modules=size cached_dcl_modules
43
44


45
  	# (ok, icl_mod, dcl_mods, groups, cached_dcl_macros,main_dcl_module_n,heaps, predef_symbols, symbol_table, error, directly_imported_dcl_modules)
46
  	  	= checkModule mod global_fun_range mod_functions support_dynamics dynamic_type_used dcl_module_n_in_cache optional_dcl_mod modules cached_dcl_modules cached_dcl_macros predef_symbols symbol_table error heaps
47

48
	  hash_table = { hash_table & hte_symbol_heap = symbol_table}
49

50
	| not ok
51
		= (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
52
53
54
55
56
57

	#! (icl_functions,icl_mod) = select_and_remove_icl_functions_from_record icl_mod
		with
			select_and_remove_icl_functions_from_record :: !*IclModule -> (!.{#FunDef},!.IclModule)
			select_and_remove_icl_functions_from_record icl_mod=:{icl_functions} = (icl_functions,{icl_mod & icl_functions={}})

58
	# {icl_common,icl_function_indices,icl_name,icl_imported_instances,icl_imported_objects,icl_foreign_exports,icl_used_module_numbers} = icl_mod
59
/*
60
	  (_,f,files) = fopen "components" FWriteText files
61
	  (groups, icl_functions, f) = showGroups groups 0 True icl_functions f
62
63
64
65
66
	/*	
	  (n_functions,icl_functions) = usize icl_functions
	  (icl_functions,f) = showFunctions {ir_from=0,ir_to=n_functions} icl_functions f
	  (cached_dcl_macros,f) = showMacros cached_dcl_macros f
	*/
67
68
69
	  (ok,files) = fclose f files
	| ok<>ok
		= abort "";
70
*/
71

72
//	# dcl_mods = {{dcl_mod & dcl_declared={dcls_import={},dcls_local=[],dcls_local_for_import={},dcls_explicit={}}}\\ dcl_mod<-:dcl_mods}
73

74
	# type_heaps = heaps.hp_type_heaps
75
76
	  fun_defs = icl_functions

77
	| options.feo_up_to_phase == FrontEndPhaseCheck
78
		# array_instances = {ali_array_first_instance_indices=[],ali_list_first_instance_indices=[],ali_tail_strict_list_first_instance_indices=[],ali_instances_range={ir_from=0,ir_to=0}}
79
		=	frontSyntaxTree cached_dcl_macros dcl_mods main_dcl_module_n
80
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs (groups_to_components groups) array_instances heaps
81

82
	# error_admin = {ea_file = error, ea_loc = [], ea_ok = True }
83
/*
84
85
	# (ti_common_defs, dcl_mods) = get_common_defs dcl_mods
	  ti_common_defs = { ti_common_defs & [main_dcl_module_n] = icl_common }
86
87
88
89
90
91
*/

	# (cached_dcl_mods, dcl_mods) = copy_dcl_modules dcl_mods
	
	# (type_groups, ti_common_defs, td_infos, icl_common, dcl_mods, type_heaps, error_admin)
			= partionateAndExpandTypes icl_used_module_numbers main_dcl_module_n icl_common dcl_mods type_heaps error_admin
92
93
94
//	  ti_common_defs = { ti_common_defs & [main_dcl_module_n] = icl_common }
//	# (td_infos, th_vars, error_admin) = analyseTypeDefs ti_common_defs type_groups td_infos type_heaps.th_vars error_admin
	  ({com_type_defs}, ti_common_defs) = replace ti_common_defs main_dcl_module_n icl_common
95
96

	# hp_var_heap = heaps.hp_var_heap
John van Groningen's avatar
John van Groningen committed
97
98
	#! n_types_with_type_functions = size ti_common_defs.[main_dcl_module_n].com_type_defs
	#! n_constructors_with_type_functions = size ti_common_defs.[main_dcl_module_n].com_cons_defs
99
	#! ea_ok = error_admin.ea_ok
100
	# (fun_defs, predef_symbols, hp_var_heap, type_heaps)
101
		= if (support_dynamics && ea_ok)
John van Groningen's avatar
John van Groningen committed
102
103
104
105
			(buildTypeFunctions main_dcl_module_n fun_defs ti_common_defs predef_symbols hp_var_heap type_heaps)
			(fun_defs, predef_symbols, hp_var_heap, type_heaps)
	# (td_infos, th_vars, error_admin)
		= analyseTypeDefs ti_common_defs type_groups com_type_defs main_dcl_module_n td_infos type_heaps.th_vars error_admin
106
	# (class_infos, td_infos, th_vars, error_admin)
John van Groningen's avatar
John van Groningen committed
107
		= determineKindsOfClasses icl_used_module_numbers ti_common_defs td_infos th_vars error_admin
108
109
110

	# icl_global_functions=icl_function_indices.ifi_global_function_indices

111
	# (fun_defs, dcl_mods, td_infos, th_vars, hp_expression_heap, gen_heap, error_admin)
John van Groningen's avatar
John van Groningen committed
112
		= checkKindsOfCommonDefsAndFunctions n_cached_dcl_modules main_dcl_module_n icl_used_module_numbers
113
				(icl_global_functions++[icl_function_indices.ifi_local_function_indices])
114
				ti_common_defs fun_defs dcl_mods td_infos class_infos th_vars heaps.hp_expression_heap heaps.hp_generic_heap error_admin
115

116
      type_heaps = { type_heaps & th_vars = th_vars }
117

118
	# heaps = { heaps & hp_type_heaps = type_heaps, hp_expression_heap = hp_expression_heap, hp_generic_heap = gen_heap, hp_var_heap=hp_var_heap }
119
120
121
122

	| not error_admin.ea_ok
		= (No,{},dcl_mods,main_dcl_module_n,predef_symbols, hash_table, files, error_admin.ea_file, io, out, tcl_file, heaps)

123
	# (saved_main_dcl_common, ti_common_defs) = replace {#dcl_common \\ {dcl_common}<-:dcl_mods} main_dcl_module_n icl_common
124

125
	#! (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin)
126
127
		= case options.feo_generics of
			True
128
				-> convertGenerics main_dcl_module_n icl_used_module_numbers ti_common_defs groups fun_defs
129
									td_infos heaps hash_table predef_symbols dcl_mods cached_dcl_macros error_admin
130
			False
131
				-> (ti_common_defs, groups, fun_defs, td_infos, heaps, hash_table, predef_symbols, dcl_mods, cached_dcl_macros, error_admin)
132

133
	# (icl_common, ti_common_defs) = replace {#x \\ x<-:ti_common_defs} main_dcl_module_n saved_main_dcl_common		
134

135
	# dcl_mods = { {dcl_mod & dcl_common = common} \\ dcl_mod <-: dcl_mods & common <-: ti_common_defs }
136
137

	# icl_mod = {icl_mod & icl_common = icl_common} 
138
		
139
	# error = error_admin.ea_file
140
141

/*
142
143
	# (_,genout,files) = fopen "genout" FWriteText files
	# (n_fun_defs,fun_defs) = usize fun_defs
144
	# (fun_defs, genout) = show_group [0..n_fun_defs-1] True fun_defs genout
145
	# (ok,files) = fclose genout files
146
	| not ok = abort "could not write genout" 
147
*/
148
149
	#! ok = error_admin.ea_ok
	| not ok
150
		= (No,{},{},main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
151

152
	# (ok, fun_defs, array_instances, common_defs, imported_funs, type_def_infos, heaps, predef_symbols, error,out)
153
154
		= typeProgram groups main_dcl_module_n fun_defs icl_function_indices.ifi_specials_indices list_inferred_types icl_common icl_imported_instances dcl_mods icl_used_module_numbers
			td_infos heaps predef_symbols error out
155

156
	| not ok
157
		= (No,{},{},main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
158
159

	# icl_gencase_indices = icl_function_indices.ifi_gencase_indices
160
	# icl_function_indices = {icl_function_indices & ifi_gencase_indices = icl_gencase_indices }
161

162
	# (fun_def_size, fun_defs) = usize fun_defs
John van Groningen's avatar
John van Groningen committed
163
164
	# (components, fun_defs)
		= partitionateFunctions fun_defs (icl_global_functions++icl_function_indices.ifi_instance_indices
165
166
											++[icl_function_indices.ifi_specials_indices
											  : icl_gencase_indices++icl_function_indices.ifi_type_function_indices])
167
		
168
	| options.feo_up_to_phase == FrontEndPhaseTypeCheck
169
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n
170
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
171

John van Groningen's avatar
John van Groningen committed
172
173
174
175
	# (dcl_types, components, fun_defs, predef_symbols, var_heap, type_heaps, expression_heap, tcl_file)
  		= convertDynamicPatternsIntoUnifyAppls common_defs main_dcl_module_n dcl_mods icl_mod directly_imported_dcl_modules
			n_types_with_type_functions n_constructors_with_type_functions
				  components fun_defs predef_symbols heaps.hp_var_heap heaps.hp_type_heaps heaps.hp_expression_heap tcl_file
176

177
	| options.feo_up_to_phase == FrontEndPhaseConvertDynamics
178
		# heaps = {hp_var_heap=var_heap, hp_type_heaps=type_heaps, hp_expression_heap=expression_heap, hp_generic_heap=newHeap}
179
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n
180
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
181

182
	#  (stdStrictLists_module_n,predef_symbols) = get_StdStrictLists_module_n predef_symbols
183

184
	# (cleanup_info, acc_args, components, fun_defs, var_heap, expression_heap)
185
		 = analyseGroups common_defs imported_funs array_instances.ali_instances_range main_dcl_module_n stdStrictLists_module_n components fun_defs var_heap expression_heap
186

187
188
189
	# (def_max, acc_args)		= usize acc_args
	# (def_min, fun_defs)		= usize fun_defs

190
	  (components, fun_defs, dcl_types, used_conses, var_heap, type_heaps, expression_heap, error, predef_symbols)
191
	  	= transformGroups cleanup_info main_dcl_module_n stdStrictLists_module_n def_min def_max components fun_defs acc_args common_defs imported_funs dcl_types type_def_infos var_heap type_heaps expression_heap options.feo_fusion error predef_symbols
192
193

	# error_admin = {ea_file = error, ea_loc = [], ea_ok = True }
194
	# {dcl_instances,dcl_specials,dcl_gencases,dcl_type_funs} = dcl_mods.[main_dcl_module_n]
195
	# (start_function_index,predef_symbols) = get_index_of_start_rule main_dcl_module_n predef_symbols
196

197
198
	# (error_admin,predef_symbols,fun_defs)
		= checkForeignExportedFunctionTypes icl_foreign_exports error_admin predef_symbols fun_defs	
John van Groningen's avatar
John van Groningen committed
199
	
200
	# [icl_exported_global_functions,icl_not_exported_global_functions:_] = icl_global_functions
201
	# exported_global_functions = case start_function_index of
202
203
				NoIndex	-> [icl_exported_global_functions]
				sri		-> [{ir_from=sri,ir_to=inc sri},icl_exported_global_functions]
204
	# exported_functions = exported_global_functions ++  [dcl_instances,dcl_specials,dcl_gencases,dcl_type_funs]
205
	# (components, fun_defs, predef_symbols, var_heap, expression_heap, error_admin) 
206
		= case options.feo_fusion.strip_unused of
207
			True -> partitionateFunctions` fun_defs (exported_functions ++ [icl_function_indices.ifi_type_function_indices!!1])
208
209
						main_dcl_module_n def_min def_max predef_symbols var_heap expression_heap error_admin
			_ 
210
				-> case options.feo_fusion.compile_with_fusion of
211
212
213
214
215
					True
						# (fun_defs,predef_symbols,var_heap,expression_heap,error_admin)
								= stripStrictLets fun_defs predef_symbols var_heap expression_heap error_admin
						-> (components, fun_defs, predef_symbols, var_heap, expression_heap, error_admin)
					_	-> (components, fun_defs, predef_symbols, var_heap, expression_heap, error_admin)
216
217
218
219

	# error = error_admin.ea_file
	| not error_admin.ea_ok
		# heaps = {hp_var_heap=var_heap, hp_type_heaps=type_heaps, hp_expression_heap=expression_heap,hp_generic_heap=heaps.hp_generic_heap}
220
		= (No,{},{},main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
221

222
	| options.feo_up_to_phase == FrontEndPhaseTransformGroups
223
		# heaps = {hp_var_heap=var_heap, hp_type_heaps=type_heaps, hp_expression_heap=expression_heap,hp_generic_heap=heaps.hp_generic_heap}
224
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n
225
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
226

227
228
	# (dcl_types,used_conses,var_heap,type_heaps) = convertIclModule main_dcl_module_n common_defs dcl_types used_conses var_heap type_heaps
	# (dcl_types,used_conses,var_heap,type_heaps) = convertDclModule main_dcl_module_n dcl_mods common_defs dcl_types used_conses var_heap type_heaps
229
230

//	  (components, fun_defs, out) = showComponents components 0 False fun_defs out
231

232
	| options.feo_up_to_phase == FrontEndPhaseConvertModules
233
		# heaps = {hp_var_heap=var_heap, hp_type_heaps=type_heaps, hp_expression_heap=expression_heap,hp_generic_heap=heaps.hp_generic_heap}
234
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods main_dcl_module_n
235
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
236

237
238
//	  (components, fun_defs, out) = showComponents components 0 False fun_defs out
	# (used_funs, components, fun_defs, dcl_types, used_conses, var_heap, type_heaps, expression_heap)
239
	  		= convertCasesOfFunctions components main_dcl_module_n imported_funs common_defs fun_defs dcl_types used_conses
240
					var_heap type_heaps expression_heap
241
242
243
244

	# (dcl_types,used_conses,var_heap,type_heaps)
		= convertMemberTypes main_dcl_module_n dcl_mods common_defs icl_used_module_numbers dcl_types used_conses var_heap type_heaps

245
	#!  (dcl_types, type_heaps, var_heap)
246
			= convertImportedTypeSpecifications main_dcl_module_n dcl_mods imported_funs common_defs used_conses used_funs dcl_types type_heaps var_heap		
247
248
249
//	# (components, fun_defs, error)	= showTypes components 0 fun_defs error
//	# (dcl_mods, out) = showDclModules dcl_mods out
//	# (components, fun_defs, out) = showComponents components 0 False fun_defs out
250

251
252
253
254
255
256
257
/*
	# (_,f,files) = fopen "components2" FWriteText files
	  (components, fun_defs, f) = showComponents components 0 False fun_defs f
	  (ok,files) = fclose f files
	| ok<>ok
		= abort "";
*/
258

259
260
//	# (fun_defs,out,var_heap,predef_symbols) = sa components main_dcl_module_n dcl_mods fun_defs out var_heap predef_symbols;

261
	# heaps = {hp_var_heap = var_heap, hp_expression_heap=expression_heap, hp_type_heaps=type_heaps,hp_generic_heap=heaps.hp_generic_heap}
262
	# 	fe ={	fe_icl = {icl_functions=fun_defs, icl_function_indices=icl_function_indices, icl_common=icl_common,
263
						 icl_imported_instances=icl_imported_instances, icl_imported_objects=icl_imported_objects,
264
						 icl_foreign_exports=icl_foreign_exports,icl_name=icl_name,icl_used_module_numbers=icl_used_module_numbers,
265
						 icl_modification_time=icl_mod.icl_modification_time }
266
267
			,	fe_dcls = dcl_mods
			,	fe_components = components
268
			,	fe_arrayInstances = array_instances
269
			}
270

271
	# cached_dcl_macros = clear_group_indices_of_macros cached_dcl_macros
272
	= (Yes fe,cached_dcl_macros,cached_dcl_mods,main_dcl_module_n,predef_symbols,hash_table,files,error,io,out,tcl_file,heaps)
273
	where
274
		copy_dcl_modules :: !*{#DclModule} -> *(!*{#DclModule},!*{#DclModule})
275
276
277
		copy_dcl_modules dcl_mods
			#! nr_of_dcl_mods = size dcl_mods
			= arrayCopyBegin dcl_mods nr_of_dcl_mods
278

279
280
		clear_group_indices_of_macros :: !*{#*{#FunDef}} -> *{#*{#FunDef}}
		clear_group_indices_of_macros cached_dcl_macros
281
			= clear_group_indices1 0 cached_dcl_macros
282
		where
283
284
			clear_group_indices1 :: !Int !*{#*{#u:FunDef}} -> *{#*{#FunDef}}
			clear_group_indices1 i cached_dcl_macros
285
286
				| i==size cached_dcl_macros
					= cached_dcl_macros
287
					# (cached_dcl_macros_i,cached_dcl_macros) = cached_dcl_macros![i]
288
					# cached_dcl_macros_i = clear_group_indices2 0 cached_dcl_macros_i
289
290
					# cached_dcl_macros = {cached_dcl_macros & [i]=cached_dcl_macros_i}
					= clear_group_indices1 (i+1) cached_dcl_macros
291
292
293
294
295
296
297

			clear_group_indices2 j cached_dcl_macros_i
				| j==size cached_dcl_macros_i
					= cached_dcl_macros_i
					# cached_dcl_macros_i = {cached_dcl_macros_i & [j].fun_info.fi_group_index= (-1)}
					= clear_group_indices2 (j+1) cached_dcl_macros_i	

298
299
300
301
302
303
304
305
306
307
308
309
		get_StdStrictLists_module_n predef_symbols
  			# (pre_mod,predef_symbols) = predef_symbols![PD_StdStrictLists]
			| pre_mod.pds_def<>NoIndex
				= (pre_mod.pds_def,predef_symbols)
				= (-1,predef_symbols)

		get_index_of_start_rule main_dcl_module_n predef_symbols
			# ({pds_def, pds_module}, predef_symbols) = predef_symbols![PD_Start]
			| pds_def <> NoIndex && pds_module == main_dcl_module_n
				= (pds_def, predef_symbols)
				= (NoIndex, predef_symbols)

310
311
312
313
314
315
	groups_to_components groups
		= {{component_members=group_members_to_component_members group_members} \\ {group_members}<-:groups}
	where
		group_members_to_component_members [e:l] = ComponentMember e (group_members_to_component_members l)
		group_members_to_component_members [] = NoComponentMembers
		
316
317
318
319
newSymbolTable :: !Int -> *{# SymbolTableEntry}
newSymbolTable size
	= createArray size {  ste_index = NoIndex, ste_def_level = -1, ste_kind = STE_Empty, ste_previous = abort "PreviousPlaceholder"}

Sjaak Smetsers's avatar
Sjaak Smetsers committed
320
321
322
323
324
325
326
showFunctions :: !IndexRange !*{# FunDef} !*File  -> (!*{# FunDef},!*File)
showFunctions {ir_from, ir_to} fun_defs file
	= iFoldSt show_function ir_from ir_to (fun_defs, file)
where
	show_function fun_index (fun_defs, file)
		# (fd, fun_defs) = fun_defs![fun_index]
		= (fun_defs, file <<< fun_index <<< fd <<< '\n')
327

328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
showMacros :: !*{#*{#FunDef}} !*File -> (!*{#*{#FunDef}},!*File)
showMacros macro_defs file
	#! n_dcl_modules=size macro_defs
	= iFoldSt showMacrosInModule 0 n_dcl_modules (macro_defs,file)

showMacrosInModule :: !Int (!*{#*{#FunDef}},!*File) -> (!*{#*{#FunDef}},!*File)
showMacrosInModule dcl_index (macro_defs,file)
	# file=file <<< dcl_index <<< '\n'
	#! n_macros=size macro_defs.[dcl_index]
	= iFoldSt show_macro 0 n_macros (macro_defs,file)
	where
		show_macro macro_index (macro_defs, file)
			# (macro,macro_defs) = macro_defs![dcl_index,macro_index]
			= (macro_defs, file <<< macro_index <<< macro <<< '\n')

343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
showGroups :: !u:{! Group} !Int !Bool !*{# FunDef} !*File  -> (!u:{! Group}, !*{# FunDef},!*File)
showGroups comps comp_index show_types fun_defs file
	| comp_index >= size comps
		= (comps, fun_defs, file)
		# (comp, comps) = comps![comp_index]
		# (fun_defs, file) = show_group comp.group_members show_types fun_defs (file <<< "component " <<< comp_index <<< '\n')
		= showGroups comps (inc comp_index) show_types fun_defs file

show_group [] show_types fun_defs file
	= (fun_defs, file <<< '\n')
show_group [fun:funs] show_types fun_defs file
	# (fun_def, fun_defs) = fun_defs![fun]
	# file=file<<<fun<<<'\n'
	| show_types
		= show_group funs show_types fun_defs (file <<< fun_def.fun_type <<< '\n' <<< fun_def)
		= show_group funs show_types fun_defs (file <<< fun_def)
//		= show_group funs show_types fun_defs (file <<< fun_def.fun_ident)

showComponents :: !u:{!Component} !Int !Bool !*{# FunDef} !*File  -> (!u:{!Component}, !*{# FunDef},!*File)
362
363
364
365
showComponents comps comp_index show_types fun_defs file
	| comp_index >= size comps
		= (comps, fun_defs, file)
		# (comp, comps) = comps![comp_index]
366
		# (fun_defs, file) = show_component comp.component_members show_types fun_defs (file <<< "component " <<< comp_index <<< '\n')
367
368
		= showComponents comps (inc comp_index) show_types fun_defs file

369
show_component NoComponentMembers show_types fun_defs file
370
	= (fun_defs, file <<< '\n')
371
372
373
374
375
376
377
378
show_component (ComponentMember fun funs) show_types fun_defs file
	# (fun_def, fun_defs) = fun_defs![fun]
	# file=file<<<fun<<<'\n'
	| show_types
		= show_component funs show_types fun_defs (file <<< fun_def.fun_type <<< '\n' <<< fun_def)
		= show_component funs show_types fun_defs (file <<< fun_def)
//		= show_component funs show_types fun_defs (file <<< fun_def.fun_ident)
show_component (GeneratedComponentMember fun _ funs) show_types fun_defs file
379
380
381
382
383
384
	# (fun_def, fun_defs) = fun_defs![fun]
	# file=file<<<fun<<<'\n'
	| show_types
		= show_component funs show_types fun_defs (file <<< fun_def.fun_type <<< '\n' <<< fun_def)
		= show_component funs show_types fun_defs (file <<< fun_def)
//		= show_component funs show_types fun_defs (file <<< fun_def.fun_ident)
385
386
387
388
389
390
391
392
393
394
395
396

showTypes :: !*{! Group} !Int !*{# FunDef} !*File  -> (!*{! Group}, !*{# FunDef},!*File)
showTypes comps comp_index fun_defs file
	| comp_index >= size comps
		= (comps, fun_defs, file)
		# (comp, comps) = comps![comp_index]
		# (fun_defs, file) = show_types comp.group_members fun_defs (file <<< "component " <<< comp_index <<< '\n')
		= showTypes comps (inc comp_index) fun_defs file
where
	show_types [] fun_defs file
		= (fun_defs, file <<< '\n')
	show_types [fun:funs] fun_defs file
397
		# (fun_def, fun_defs) = fun_defs![fun]
398
399
		# properties = { form_properties = cAttributed bitor cAnnotated, form_attr_position = No }
		  (Yes ftype) = fun_def.fun_type
400
		= show_types funs fun_defs (file <<< fun_def.fun_ident <<< " :: " <:: (properties, ftype, No) <<< '\n' )
401
402
403
404
405
406
407
408
409

showDclModules :: !u:{#DclModule} !*File -> (!u:{#DclModule}, !*File)
showDclModules dcl_mods file
	= show_dcl_mods 0 dcl_mods file
where
	show_dcl_mods mod_index dcl_mods file
		# (size_dcl_mods, dcl_mods) = usize dcl_mods
		| mod_index == size_dcl_mods
			= (dcl_mods, file)
410
			# (dcl_mod, dcl_mods) = dcl_mods![mod_index]
411
			# file = show_dcl_mod dcl_mod file
412
			= show_dcl_mods (mod_index+1) dcl_mods file
413
414
415
416
417
418
419
420
421
422
423
			
	show_dcl_mod {dcl_name, dcl_functions} file
		# file = file <<< dcl_name <<< ":\n"
		# file = show_dcl_functions 0 dcl_functions file
		= file <<< "\n"
	show_dcl_functions fun_index dcl_functions file					 				
		| fun_index == size dcl_functions
			= file
		| otherwise
			# file = show_dcl_function dcl_functions.[fun_index] file
			= show_dcl_functions (inc fun_index) dcl_functions file 
424
425
	show_dcl_function {ft_ident, ft_type} file
		= file <<< ft_ident <<< " :: " <<< ft_type <<< "\n"			
426
		
427
428
429
430
431
432
433
434
435
436
437
instance == ListTypesKind where
	(==) ListTypesNone ListTypesNone
		=	True
	(==) ListTypesInferred ListTypesInferred
		=	True
	(==) ListTypesStrictExports ListTypesStrictExports
		=	True
	(==) ListTypesAll ListTypesAll
		=	True
	(==) _ _
		=	False