frontend.icl 20.2 KB
Newer Older
1 2 3
/*
	module owner: Ronny Wichers Schreur
*/
4 5
implementation module frontend

6
import scanner, parse, postparse, check, type, trans, convertcases, overloading, utilities, convertDynamics,
7
		convertimportedtypes, /*checkKindCorrectness, */ compilerSwitches, analtypes, generics
8

9
//import print
John van Groningen's avatar
John van Groningen committed
10

11 12
:: FrontEndOptions 
	=	{	feo_up_to_phase			:: !FrontEndPhase
13 14
		,	feo_generics 			:: !Bool
		,	feo_fusion	 			:: !Bool
15 16
		}

17
:: FrontEndSyntaxTree
18 19 20 21
	=	{	fe_icl					:: !IclModule
		,	fe_dcls					:: !{#DclModule}
		,	fe_components			:: !{!Group}
		,	fe_arrayInstances		:: !ArrayAndListInstances
22 23 24 25 26
		}

// trace macro
(-*->) infixl
(-*->) value trace
clean's avatar
clean committed
27
	:==	value // ---> trace
28

29 30 31 32 33 34 35 36 37 38 39 40
:: FrontEndPhase
	=	FrontEndPhaseCheck
	|	FrontEndPhaseTypeCheck
	|	FrontEndPhaseConvertDynamics
	|	FrontEndPhaseTransformGroups
	|	FrontEndPhaseConvertModules
	|	FrontEndPhaseAll

instance == FrontEndPhase where
	(==) a b
		=	equal_constructor a b

41
frontSyntaxTree cached_dcl_macros cached_dcl_mods n_functions_and_macros_in_dcl_modules main_dcl_module_n predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
42 43 44 45 46
	:== (Yes {
				fe_icl = {icl_mod & icl_functions=fun_defs }
			,	fe_dcls = dcl_mods
			,	fe_components = components
			,	fe_arrayInstances = array_instances
47
			},cached_dcl_macros,cached_dcl_mods,n_functions_and_macros_in_dcl_modules,main_dcl_module_n,predef_symbols,hash_table,files,error,io,out,tcl_file,heaps
48 49
		)

50
// import StdDebug
51

52 53
frontEndInterface :: !FrontEndOptions !Ident !SearchPaths !{#DclModule} !*{#*{#FunDef}} !(Optional Bool) !*PredefinedSymbols !*HashTable (ModTimeFunction *Files) !*Files !*File !*File !*File (!Optional !*File) !*Heaps
  	-> ( !Optional *FrontEndSyntaxTree,!*{#*{#FunDef}},!{#DclModule},!Int,!Int,!*PredefinedSymbols, !*HashTable, !*Files, !*File, !*File, !*File, !Optional !*File, !*Heaps) 
54
frontEndInterface options mod_ident search_paths cached_dcl_modules functions_and_macros list_inferred_types predef_symbols hash_table modtimefunction files error io out tcl_file heaps 
55
// 	# files = trace_n ("Compiling "+++mod_ident.id_name) files
56 57
	# (ok, mod, hash_table, error, files)
		= wantModule cWantIclFile mod_ident NoPos options.feo_generics(hash_table /* ---> ("Parsing:", mod_ident)*/) error search_paths modtimefunction files
58
	| not ok
59
		= (No,{},{},0,0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
60

John van Groningen's avatar
John van Groningen committed
61
	# cached_module_idents = [dcl_mod.dcl_name \\ dcl_mod<-:cached_dcl_modules]
62 63
	# (ok, mod, global_fun_range, mod_functions, optional_dcl_mod, modules, dcl_module_n_in_cache,n_functions_and_macros_in_dcl_modules,hash_table, error, files)
		= scanModule (mod -*-> "Scanning") cached_module_idents options.feo_generics hash_table error search_paths modtimefunction files
64 65 66 67
	/* JVG: */
//	# hash_table = {hash_table & hte_entries={}}
	# hash_table = remove_icl_symbols_from_hash_table hash_table
	/**/
68
	| not ok
69
		= (No,{},{},0,0,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
70
  	# symbol_table = hash_table.hte_symbol_heap
John van Groningen's avatar
John van Groningen committed
71
  	#! n_cached_dcl_modules=size cached_dcl_modules
72
  	# (ok, icl_mod, dcl_mods, components, cached_dcl_macros,main_dcl_module_n,heaps, predef_symbols, symbol_table, error, directly_imported_dcl_modules)
John van Groningen's avatar
John van Groningen committed
73
  	  	= checkModule mod global_fun_range mod_functions n_functions_and_macros_in_dcl_modules dcl_module_n_in_cache optional_dcl_mod modules cached_dcl_modules functions_and_macros predef_symbols (symbol_table -*-> "Checking") error heaps
74
	  hash_table = { hash_table & hte_symbol_heap = symbol_table}
75

76
	| not ok
77
		= (No,{},dcl_mods,0,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
78 79 80 81 82 83

	#! (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={}})

84
	# {icl_global_functions,icl_instances,icl_specials,icl_common,icl_import,icl_name,icl_imported_objects,icl_used_module_numbers,icl_copied_from_dcl} = icl_mod
85 86
/*
	  (_,f,files) = fopen "components" FWriteText files
87
	  (components, icl_functions, f) = showComponents components 0 True icl_functions f
88 89 90 91 92
	/*	
	  (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
	*/
93 94 95 96
	  (ok,files) = fclose f files
	| ok<>ok
		= abort "";
*/
97

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

100
	# var_heap = heaps.hp_var_heap
Martijn Vervoort's avatar
Martijn Vervoort committed
101
	  type_heaps = heaps.hp_type_heaps
102 103
	  fun_defs = icl_functions

104
	| options.feo_up_to_phase == FrontEndPhaseCheck
105
		# 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}}
106 107
		=	frontSyntaxTree cached_dcl_macros dcl_mods n_functions_and_macros_in_dcl_modules main_dcl_module_n
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
108

109
	# error_admin = {ea_file = error, ea_loc = [], ea_ok = True }
110
/*
111 112
	# (ti_common_defs, dcl_mods) = get_common_defs dcl_mods
	  ti_common_defs = { ti_common_defs & [main_dcl_module_n] = icl_common }
113 114 115 116 117 118 119
*/

	# (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
	  ti_common_defs = { ti_common_defs & [main_dcl_module_n] = icl_common }
120 121
	# (td_infos, th_vars, error_admin) = analyseTypeDefs ti_common_defs type_groups td_infos type_heaps.th_vars error_admin
/*
John van Groningen's avatar
John van Groningen committed
122
	  (fun_defs, dcl_mods, th_vars, td_infos, error_admin) 
123
      		= checkKindCorrectness main_dcl_module_n nr_of_cached_functions_and_macros icl_instances ti_common_defs n_cached_dcl_modules fun_defs dcl_mods type_heaps.th_vars td_infos error_admin
124 125 126 127
*/
	  (class_infos, td_infos, th_vars, error_admin)
			= determineKindsOfClasses icl_used_module_numbers ti_common_defs td_infos th_vars error_admin
	# (fun_defs, dcl_mods, td_infos, th_vars, error_admin)
128
			= checkKindsOfCommonDefsAndFunctions n_cached_dcl_modules main_dcl_module_n icl_used_module_numbers icl_global_functions
129 130
				ti_common_defs fun_defs dcl_mods td_infos class_infos th_vars error_admin

131
      type_heaps = { type_heaps & th_vars = th_vars }
132

133
	# heaps = { heaps & hp_type_heaps = type_heaps }
134 135 136 137 138 139
	# (saved_main_dcl_common, ti_common_defs) = replace (dcl_common_defs dcl_mods) main_dcl_module_n icl_common
		with 
			dcl_common_defs :: .{#DclModule} -> .{#CommonDefs} // needed for Clean 2.0 to disambiguate overloading
			dcl_common_defs dcl_mods
				=	{dcl_common \\ {dcl_common} <-: dcl_mods }

140
	#! (components, ti_common_defs, fun_defs, generic_range, td_infos, heaps, hash_table, predef_symbols, dcl_mods, error_admin) = 
John van Groningen's avatar
John van Groningen committed
141
		SwitchGenerics
John van Groningen's avatar
John van Groningen committed
142 143
			(case options.feo_generics of
				True -> 
144
					convertGenerics
John van Groningen's avatar
John van Groningen committed
145
							components main_dcl_module_n ti_common_defs fun_defs td_infos 
146
							heaps hash_table predef_symbols dcl_mods error_admin
John van Groningen's avatar
John van Groningen committed
147
				False -> 
148
					(components, ti_common_defs, fun_defs, {ir_to=0,ir_from=0}, td_infos, heaps, hash_table, predef_symbols, dcl_mods, error_admin)
John van Groningen's avatar
John van Groningen committed
149
			)
150
			(components, ti_common_defs, fun_defs, {ir_to=0,ir_from=0}, td_infos, heaps, hash_table, predef_symbols, dcl_mods, error_admin)	
151 152 153 154 155
	# (icl_common, ti_common_defs) = replace copied_ti_common_defs main_dcl_module_n saved_main_dcl_common		
		with 
			copied_ti_common_defs :: !.{#CommonDefs} // needed for Clean 2.0 to disambiguate overloading of replace
			copied_ti_common_defs = {x \\ x <-: ti_common_defs}

156
	# dcl_mods = { {dcl_mod & dcl_common = common} \\ dcl_mod <-: dcl_mods & common <-: ti_common_defs }
157 158

	# icl_mod = {icl_mod & icl_common = icl_common} 
159
		
160
	# error = error_admin.ea_file
161 162 163 164 165 166 167 168

/*
	# (_,genout,files) = fopen "c:\\Generics\\genout.icl" FWriteText files
	# (fun_defs, genout) = printFunDefs fun_defs genout
	# (ok,files) = fclose genout files
	| not ok = abort "could not write genout.icl" 
*/

169 170
	#! ok = error_admin.ea_ok
	| not ok
171
		= (No,{},{},0,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
172

173
	# (ok, fun_defs, array_instances, type_code_instances, common_defs, imported_funs, type_def_infos, heaps, predef_symbols, error,out)
174
		= typeProgram (components -*-> "Typing") main_dcl_module_n fun_defs/*icl_functions*/ icl_specials list_inferred_types icl_common [a\\a<-:icl_import] dcl_mods icl_used_module_numbers td_infos heaps predef_symbols error out dcl_mods
175

176
	| not ok
177
		= (No,{},{},0,main_dcl_module_n,predef_symbols, hash_table, files, error, io, out, tcl_file, heaps)
178
			
179

180
	# (fun_def_size, fun_defs) = usize fun_defs
181
	# (components, fun_defs) 	= partitionateFunctions (fun_defs -*-> "partitionateFunctions") (icl_global_functions++icl_instances++[icl_specials, generic_range])
182
		
Sjaak Smetsers's avatar
Sjaak Smetsers committed
183
//	  (components, fun_defs, error)	= showTypes components 0 fun_defs error
184
//	  (components, fun_defs, out)	= showComponents components 0 True fun_defs out
Sjaak Smetsers's avatar
Sjaak Smetsers committed
185
//	  (fun_defs, error)	= showFunctions array_instances fun_defs error
186
		
187
	| options.feo_up_to_phase == FrontEndPhaseTypeCheck
188 189
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods n_functions_and_macros_in_dcl_modules main_dcl_module_n
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
190

191
	# (components, fun_defs, predef_symbols, dcl_types, used_conses_in_dynamics, var_heap, type_heaps, expression_heap, tcl_file)
192
	  		= convertDynamicPatternsIntoUnifyAppls type_code_instances common_defs main_dcl_module_n (components -*-> "convertDynamics") fun_defs predef_symbols
193
					heaps.hp_var_heap heaps.hp_type_heaps heaps.hp_expression_heap tcl_file dcl_mods icl_mod directly_imported_dcl_modules
194 195
//	#  (components, fun_defs, error) = showComponents3 components 0 False fun_defs error
//	  (components, fun_defs, error)	= showComponents components 0 True fun_defs error
196

197
	| options.feo_up_to_phase == FrontEndPhaseConvertDynamics
198
		# heaps = {hp_var_heap=var_heap, hp_type_heaps=type_heaps, hp_expression_heap=expression_heap}
199 200
		=	frontSyntaxTree cached_dcl_macros cached_dcl_mods n_functions_and_macros_in_dcl_modules main_dcl_module_n
							predef_symbols hash_table files error io out tcl_file icl_mod dcl_mods fun_defs components array_instances heaps
201

202
//	  (components, fun_defs, error) = showComponents components 0 True fun_defs error
203 204 205 206 207 208 209 210

	#  (stdStrictLists_module_n,predef_symbols) = get_StdStrictLists_module_n predef_symbols
	  	with
	  		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)
211
	# (cleanup_info, acc_args, components, fun_defs, var_heap, expression_heap)
212
		 = analyseGroups common_defs imported_funs array_instances.ali_instances_range main_dcl_module_n stdStrictLists_module_n (components -*-> "Analyse") fun_defs var_heap expression_heap
213

214 215
//	# (components, fun_defs, error) = showComponents2 components 0 fun_defs acc_args error

216
	  (components, fun_defs, dcl_types, used_conses, var_heap, type_heaps, expression_heap)
217
	  	= transformGroups cleanup_info main_dcl_module_n stdStrictLists_module_n (components -*-> "Transform") fun_defs acc_args common_defs imported_funs dcl_types used_conses_in_dynamics type_def_infos var_heap type_heaps expression_heap options.feo_fusion
218

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

224 225 226 227
	# (dcl_types, used_conses, var_heap, type_heaps) = convertIclModule main_dcl_module_n common_defs (dcl_types -*-> "Convert icl") 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 -*-> "Convert dcl") used_conses var_heap type_heaps

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

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

234 235
//	  (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)
236
	  		= convertCasesOfFunctions components main_dcl_module_n imported_funs common_defs fun_defs (dcl_types -*-> "Convert cases") used_conses
237
					var_heap type_heaps expression_heap
238 239
	#!  (dcl_types, type_heaps, var_heap)
			= convertImportedTypeSpecifications main_dcl_module_n dcl_mods imported_funs common_defs used_conses used_funs (dcl_types -*-> "Convert types") type_heaps var_heap		
240 241 242
//	# (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
243

244 245 246 247 248 249 250 251 252 253
/*
	# (_,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 "";
*/
//	# (fun_defs,out,var_heap,predef_symbols) = sa components main_dcl_module_n dcl_mods fun_defs out var_heap predef_symbols;

	# heaps = {hp_var_heap = var_heap, hp_expression_heap=expression_heap, hp_type_heaps=type_heaps}
254
	# 	fe ={	fe_icl =
255
//							 {icl_mod & icl_functions=fun_defs }
256
							 {icl_functions=fun_defs,icl_global_functions=icl_global_functions,icl_instances=icl_instances,icl_specials=icl_specials,icl_common=icl_common,icl_import=icl_import,
257
							 icl_name=icl_name,icl_imported_objects=icl_imported_objects,icl_used_module_numbers=icl_used_module_numbers,
258
							 icl_copied_from_dcl=icl_copied_from_dcl,icl_modification_time=icl_mod.icl_modification_time}
259 260 261

			,	fe_dcls = dcl_mods
			,	fe_components = components
262
			,	fe_arrayInstances = array_instances
263
			}
264
	= (Yes fe,cached_dcl_macros,cached_dcl_mods,n_functions_and_macros_in_dcl_modules,main_dcl_module_n,predef_symbols,hash_table,files,error,io,out,tcl_file,heaps)
265
	where
266 267 268
		copy_dcl_modules dcl_mods
			#! nr_of_dcl_mods = size dcl_mods
			= arrayCopyBegin dcl_mods nr_of_dcl_mods
269 270 271 272 273

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
274 275 276 277 278 279 280
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')
281

282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
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')

297 298 299 300 301 302 303 304 305 306 307
showComponents :: !*{! Group} !Int !Bool !*{# FunDef} !*File  -> (!*{! Group}, !*{# FunDef},!*File)
showComponents 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_component comp.group_members show_types fun_defs (file <<< "component " <<< comp_index <<< '\n')
		= showComponents comps (inc comp_index) show_types fun_defs file
where
	show_component [] show_types fun_defs file
		= (fun_defs, file <<< '\n')
	show_component [fun:funs] show_types fun_defs file
308
		# (fun_def, fun_defs) = fun_defs![fun]
309
		# file=file<<<fun<<<'\n'
310
		| show_types
Sjaak Smetsers's avatar
Sjaak Smetsers committed
311
			= show_component funs show_types fun_defs (file <<< fun_def.fun_type <<< '\n' <<< fun_def)
312 313
			= show_component funs show_types fun_defs (file <<< fun_def)
//		= show_component funs show_types fun_defs (file <<< fun_def.fun_symb)
314

315
showComponents2 :: !*{! Group} !Int !*{# FunDef} !{! ConsClasses} !*File  -> (!*{! Group},!*{# FunDef},!*File)
316 317
showComponents2 comps comp_index fun_defs acc_args file
	| comp_index >= (size comps)
318 319 320
		= (comps, fun_defs, file)
	# (comp, comps) = comps![comp_index]
	# (fun_defs, file) = show_component comp.group_members fun_defs acc_args file
321 322 323 324 325
	= showComponents2 comps (inc comp_index) fun_defs acc_args file
where
	show_component [] fun_defs _ file
		= (fun_defs, file <<< '\n')
	show_component [fun:funs] fun_defs acc_args file
326
		# (fd, fun_defs) = fun_defs![fun]
327 328 329
		# file = file <<< fd.fun_symb <<< '.' <<< fun <<< " ("
		# file = show_accumulating_arguments acc_args.[fun].cc_args file
		# file = show_linear_arguments acc_args.[fun].cc_linear_bits file
330 331 332 333 334 335 336 337 338
		= show_component funs fun_defs acc_args (file <<< ") ")
	
	show_accumulating_arguments [ cc : ccs] file
		| cc == cPassive
			= show_accumulating_arguments ccs (file <<< 'p')
		| cc == cActive
			= show_accumulating_arguments ccs (file <<< 'c')
		| cc == cAccumulating
			= show_accumulating_arguments ccs (file <<< 'a')
339 340
		| cc == cVarOfMultimatchCase
			= show_accumulating_arguments ccs (file <<< 'm')
341 342 343 344
			= show_accumulating_arguments ccs (file <<< '?')
	show_accumulating_arguments [] file
		= file

345 346 347 348 349 350 351
	show_linear_arguments [ cc : ccs] file
		| cc == True
			= show_linear_arguments ccs (file <<< 'l')
			= show_linear_arguments ccs (file <<< 'n')
	show_linear_arguments [] file
		= file

352
//show_components comps fun_defs = map (show_component fun_defs) comps
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367

show_component fun_defs [] = []
show_component fun_defs [fun:funs] = [fun_defs.[fun ---> fun] : show_component fun_defs funs]

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
368
		# (fun_def, fun_defs) = fun_defs![fun]
369 370
		# properties = { form_properties = cAttributed bitor cAnnotated, form_attr_position = No }
		  (Yes ftype) = fun_def.fun_type
371
		= show_types funs fun_defs (file <<< fun_def.fun_symb <<< " :: " <:: (properties, ftype, No) <<< '\n' )
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396

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)
		| otherwise
			# (dcl_mod, dcl_mods) = dcl_mods ! [mod_index]	
			# file =  show_dcl_mod dcl_mod file
			= (dcl_mods, file)
			
	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 
	show_dcl_function {ft_symb, ft_type} file
397 398
		= file <<< ft_symb <<< " :: " <<< ft_type <<< "\n"			
		
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415

:: ListTypesKind = ListTypesNone | ListTypesInferred | ListTypesStrictExports | ListTypesAll
:: ListTypesOption =
	{	lto_showAttributes :: Bool
	,	lto_listTypesKind :: ListTypesKind
	}
instance == ListTypesKind where
	(==) ListTypesNone ListTypesNone
		=	True
	(==) ListTypesInferred ListTypesInferred
		=	True
	(==) ListTypesStrictExports ListTypesStrictExports
		=	True
	(==) ListTypesAll ListTypesAll
		=	True
	(==) _ _
		=	False
416