CoreTypes.dcl 27.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
/*
** Program: Clean Prover System
** Module:  CoreTypes (.dcl)
** 
** Author:  Maarten de Mol
** Created: 22 August 2000
*/

definition module 
	CoreTypes

import
	StdEnv,
	ProverOptions,
	frontend,
	Errors

// NOT (by a long shot) complete as yet.
// ------------------------------------------------------------------------------------------------------------------------
:: ABCFunctions =
// ------------------------------------------------------------------------------------------------------------------------
	{ stdBool				:: !BoolFunctions
	, stdInt				:: !IntFunctions
	}
instance DummyValue ABCFunctions

// ------------------------------------------------------------------------------------------------------------------------
:: BoolFunctions =
// ------------------------------------------------------------------------------------------------------------------------
	{ boolAnd				:: !HeapPtr
	, boolNot				:: !HeapPtr
	, boolOr				:: !HeapPtr
	}
instance DummyValue BoolFunctions

// ------------------------------------------------------------------------------------------------------------------------
:: IntFunctions =
// ------------------------------------------------------------------------------------------------------------------------
	{ intAdd				:: !HeapPtr
	, intBitAnd				:: !HeapPtr
	, intBitNot				:: !HeapPtr
	, intBitOr				:: !HeapPtr
	, intBitXor				:: !HeapPtr
	, intDivide				:: !HeapPtr
	, intEqual				:: !HeapPtr
	, intIsEven				:: !HeapPtr
	, intIsOdd				:: !HeapPtr
	, intModulo				:: !HeapPtr
	, intMultiply			:: !HeapPtr
	, intOne				:: !HeapPtr
	, intNegate				:: !HeapPtr
	, intSmaller			:: !HeapPtr
	, intSubtract			:: !HeapPtr
	, intZero				:: !HeapPtr
	}
instance DummyValue IntFunctions





































// -------------------------------------------------------------------------------------------------------------------------------------------------
:: Options =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ optCombineLets				:: !Bool
	, optAutomaticDiscard			:: !Bool
	, optDisplaySpecial				:: !Bool
	, optHintsViewThreshold			:: !Int
	, optHintsApplyThreshold		:: !Int
	}
instance DummyValue Options

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CompilerDefinitionKind =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CheckedTypeDef
	| ClassDef
	| ClassInstance
	| ConsDef
	| FunDef
	| FunType
	| MemberDef
	| SelectorDef
instance DummyValue CompilerDefinitionKind
instance toString CompilerDefinitionKind
instance == CompilerDefinitionKind

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: IndexedPtr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  IclDefinitionPtr	!ModuleName !Int !CName !CompilerDefinitionKind !CDefIndex
	| DclDefinitionPtr	!ModuleName      !CName !CompilerDefinitionKind !CDefIndex
instance DummyValue IndexedPtr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: HeapPtr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CAlgTypePtr		!ModulePtr	!(Ptr CAlgTypeDefH)
	| CClassPtr			!ModulePtr	!(Ptr CClassDefH)
	| CDataConsPtr		!ModulePtr	!(Ptr CDataConsDefH)
	| CFunPtr			!ModulePtr	!(Ptr CFunDefH)
	| CInstancePtr		!ModulePtr	!(Ptr CInstanceDefH)
	| CMemberPtr		!ModulePtr	!(Ptr CMemberDefH)
	| CRecordFieldPtr	!ModulePtr	!(Ptr CRecordFieldDefH)
	| CRecordTypePtr	!ModulePtr	!(Ptr CRecordTypeDefH)
	// predefined types
	| CTuplePtr			!CArity
	| CNormalArrayPtr
	| CStrictArrayPtr
	| CUnboxedArrayPtr
	| CListPtr
	// predefined constructors
	| CBuildTuplePtr	!CArity
	| CConsPtr
	| CNilPtr
	// predefined functions
	| CTupleSelectPtr	!CArity !Int
	// dynamics
	| CTCPtr
	| CTCDictPtr
instance DummyValue HeapPtr
instance == HeapPtr
// CONVENTION: DummyValue must be distinguishable from all other pointers.

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: DefinitionKind =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CAlgType
	| CClass
	| CDataCons
	| CFun
	| CInstance
	| CMember
	| CRecordField
	| CRecordType
instance DummyValue DefinitionKind
instance toString DefinitionKind
instance == DefinitionKind

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CompilerStore =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ csAlgTypeDefs			:: ![CAlgTypeDefI]
	, csClassDefs			:: ![CClassDefI]
	, csDataConsDefs		:: ![CDataConsDefI]
	, csFunDefs				:: ![CFunDefI]
	, csInstanceDefs		:: ![CInstanceDefI]
	, csMemberDefs			:: ![CMemberDefI]
	, csRecordFieldDefs		:: ![CRecordFieldDefI]
	, csRecordTypeDefs		:: ![CRecordTypeDefI]
	, csImports				:: ![CName]
	}
instance DummyValue CompilerStore

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CompilerConversion =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	// the next tables take a solved icl-index as input and yield the right HeapPtr
	{ ccCheckedTypePtrs		:: !{!HeapPtr}
	, ccClassPtrs			:: !{!HeapPtr}
	, ccConsPtrs			:: !{!HeapPtr}
	, ccFunPtrs				:: !{!HeapPtr}
	, ccInstancePtrs		:: !{!HeapPtr}
	, ccMemberPtrs			:: !{!HeapPtr}
	, ccSelectorPtrs		:: !{!HeapPtr}
	// other conversion stuff
	, ccDictionaries		:: ![(CName, IndexedPtr)]			// list of dictionaries tupled with class name (ICL)
	, ccConversionTable		:: !ConversionTable					// from compiler
	, ccDclIclConversions	:: !{#Index}						// from compiler
	}
instance DummyValue CompilerConversion

























// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CAlgPattern def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ atpDataCons				:: !def_ptr
	, atpExprVarScope			:: ![CExprVarPtr]
	, atpResult					:: !CExpr def_ptr
	}
instance DummyValue (CAlgPattern def_ptr) | DummyValue def_ptr
instance == (CAlgPattern def_ptr) | == def_ptr
                                  
// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CAlgTypeDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ atdName					:: !CName
	, atdArity					:: !CArity                
	, atdTypeVarScope			:: ![CTypeVarPtr]
	, atdConstructors			:: ![def_ptr]
	}
instance DummyValue (CAlgTypeDef def_ptr) | DummyValue def_ptr
   
// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CBasicPattern def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ bapBasicValue				:: !CBasicValue def_ptr
	, bapResult					:: !CExpr def_ptr
	}
instance DummyValue (CBasicPattern def_ptr) | DummyValue def_ptr
instance == (CBasicPattern def_ptr) | == def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CBasicType = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CInteger
	| CCharacter
	| CRealNumber
	| CBoolean
	| CString
instance DummyValue CBasicType
instance == CBasicType

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CBasicValue def_ptr = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CBasicInteger		!Int  
	| CBasicCharacter	!Char
	| CBasicRealNumber	!Real
	| CBasicBoolean		!Bool  
	| CBasicString		!String
	| CBasicArray		!.[CExpr def_ptr]
instance DummyValue (CBasicValue def_ptr)
instance == (CBasicValue def_ptr) | == def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CCasePatterns def_ptr = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CAlgPatterns		def_ptr			!.[CAlgPattern def_ptr]
	| CBasicPatterns 	!CBasicType		!.[CBasicPattern def_ptr]
instance DummyValue (CCasePatterns def_ptr) | DummyValue def_ptr
instance == (CCasePatterns def_ptr) | == def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CClassDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ cldName					:: !CName
	, cldArity					:: !CArity
	, cldTypeVarScope			:: ![CTypeVarPtr]
	, cldClassRestrictions		:: !.[CClassRestriction def_ptr]
	, cldMembers				:: ![def_ptr]
	, cldDictionary				:: !def_ptr
	, cldInstances				:: ![def_ptr]
	}
instance DummyValue (CClassDef def_ptr) | DummyValue def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CClassRestriction def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ ccrClass					:: !def_ptr
	, ccrTypes					:: !.[CType def_ptr]
	}
instance DummyValue (CClassRestriction def_ptr) | DummyValue def_ptr
instance == (CClassRestriction def_ptr) | == def_ptr
            
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CDataConsDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ dcdName					:: !CName
	, dcdArity					:: !CArity
	, dcdAlgType				:: !def_ptr
	, dcdSymbolType				:: !CSymbolType def_ptr
	, dcdInfix					:: !CInfix
	, dcdTypeVarScope			:: ![CTypeVarPtr]       // existential typevariables
	}   
instance DummyValue (CDataConsDef def_ptr) | DummyValue def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CExpr def_ptr = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CExprVar					!CExprVarPtr
	| CShared					!CSharedPtr
	| (@#) infixr 9				!(CExpr def_ptr) !.[CExpr def_ptr]
	| (@@#) infixr 9			!def_ptr !.[CExpr def_ptr]
	| CLet						!CIsStrict !.[.(CExprVarPtr, CExpr def_ptr)] !(CExpr def_ptr)
	| CCase						!(CExpr def_ptr) !(CCasePatterns def_ptr) !.(Maybe (CExpr def_ptr))
	| CBasicValue				!(CBasicValue def_ptr)
	| CCode						!String ![String]
	| CBottom
instance DummyValue (CExpr def_ptr) | DummyValue def_ptr
instance == (CExpr def_ptr) | == def_ptr
      
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CExprVarDef =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ evarName					:: !CName
	, evarInfo					:: !CExprVarInfo
	}      
instance DummyValue CExprVarDef

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CExprVarInfo =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  EVar_Nothing 
	| EVar_InCase										// used in conversion phase only
	| EVar_Fresh				!CExprVarPtr			// always deleted afterwards
	| EVar_Num					!Int
	| EVar_Subst				!CExprH					// always deleted afterwards
	| EVar_Temp					!CExprH					// NOT always deleted afterwards (used in findStrictVars)
	| EVar_Type					!CTypeH
instance DummyValue CExprVarInfo

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CFunDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ fdName					:: !CName
	, fdOldName					:: !CName				// used when a suffix is generated for instance functions
	, fdArity					:: !CArity
	, fdCaseVariables			:: ![Int]				// indexes of variables where a case distinction is carried out on in the body
	, fdStrictVariables			:: ![Int]				// indexes of variables that are 100% certain to be strict, judging from the body
	, fdInfix					:: !CInfix
	, fdSymbolType				:: !CSymbolType def_ptr
	, fdHasType					:: !Bool
	, fdExprVarScope			:: ![CExprVarPtr]
	, fdBody					:: !CExpr def_ptr
	, fdIsRecordSelector		:: !Bool
	, fdIsRecordUpdater			:: !Bool
	, fdNrDictionaries			:: !Int
	, fdRecordFieldDef			:: !def_ptr
	, fdDeltaRule				:: !Maybe ([CExprH] -> (Error, CExprH))
	, fdOpaque					:: !Bool				// used during proving
	, fdHalting					:: !Bool				// used for definedness analysis
	}
instance DummyValue (CFunDef def_ptr) | DummyValue def_ptr
   
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CInfix =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CNoInfix
	| CLeftAssociative			!CPriority
	| CRightAssociative			!CPriority
	| CNotAssociative			!CPriority
instance DummyValue CInfix

// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CInstanceDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ indName					:: !CName
	, indClass					:: !def_ptr
	, indTypeVarScope			:: ![CTypeVarPtr]
	, indClassArguments			:: !.[CType def_ptr]
	, indClassRestrictions		:: !.[CClassRestriction def_ptr]
	, indMemberFunctions		:: ![def_ptr]
	}
instance DummyValue (CInstanceDef def_ptr) | DummyValue def_ptr
instance < (CInstanceDef def_ptr)

// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CMemberDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ mbdName					:: !CName
	, mbdClass					:: !def_ptr
	, mbdSymbolType				:: !CSymbolType def_ptr
	, mbdInfix					:: !CInfix
	}
instance DummyValue (CMemberDef def_ptr) | DummyValue def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CModule =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ pmName				:: !CName
	, pmPath				:: !String
	, pmImportedModules		:: ![ModulePtr]
	, pmAlgTypePtrs			:: ![HeapPtr]
	, pmClassPtrs			:: ![HeapPtr]
	, pmDataConsPtrs		:: ![HeapPtr]
	, pmFunPtrs				:: ![HeapPtr]
	, pmInstancePtrs		:: ![HeapPtr]
	, pmMemberPtrs			:: ![HeapPtr]
	, pmRecordTypePtrs		:: ![HeapPtr]
	, pmRecordFieldPtrs		:: ![HeapPtr]
	, pmCompilerStore		:: !Maybe CompilerStore
	, pmCompilerConversion	:: !CompilerConversion
429
	, pmOriginalNrDclConses	:: !Int						// needed for conversion of dictionary creation conses (which are translated via classes)
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
	}
instance DummyValue CModule

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CPredefined =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ preTuple				:: !CArity -> CAlgTypeDefH
	, preNormalArray		:: !CAlgTypeDefH
	, preStrictArray		:: !CAlgTypeDefH
	, preUnboxedArray		:: !CAlgTypeDefH
	, preList				:: !CAlgTypeDefH
	, preBuildTuple			:: !CArity -> CDataConsDefH
	, preCons				:: !CDataConsDefH
	, preNil				:: !CDataConsDefH
	, preTupleSelect		:: !CArity !Int -> CFunDefH
	, preTC					:: !CClassDefH
	, preTCDict				:: !CRecordTypeDefH
	}
instance DummyValue CPredefined

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CProject =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ prjModules			:: ![ModulePtr]
	, prjPredefined			:: !CPredefined
	, prjAlgTypeHeap		:: !.(Heap CAlgTypeDefH)
	, prjClassHeap			:: !.(Heap CClassDefH)
	, prjDataConsHeap		:: !.(Heap CDataConsDefH)
	, prjFunHeap			:: !.(Heap CFunDefH)
	, prjInstanceHeap		:: !.(Heap CInstanceDefH)
	, prjMemberHeap			:: !.(Heap CMemberDefH)
	, prjRecordTypeHeap		:: !.(Heap CRecordTypeDefH)
	, prjRecordFieldHeap	:: !.(Heap CRecordFieldDefH)
	, prjArraySelectMember	:: !Maybe !HeapPtr			// overloaded select
	, prjABCFunctions		:: !ABCFunctions
	}
instance DummyValue CProject

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CProp def_ptr = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CPropVar					!CPropVarPtr
	| CTrue
	| CFalse
	| CEqual					!(CExpr def_ptr) !(CExpr def_ptr)
	| CNot						!(CProp def_ptr)
	| CAnd						!(CProp def_ptr) !(CProp def_ptr)
	| COr						!(CProp def_ptr) !(CProp def_ptr)
	| CImplies					!(CProp def_ptr) !(CProp def_ptr)
	| CIff						!(CProp def_ptr) !(CProp def_ptr)
	| CExprForall				!CExprVarPtr !(CProp def_ptr)
	| CExprExists				!CExprVarPtr !(CProp def_ptr)
	| CPropForall				!CPropVarPtr !(CProp def_ptr)
	| CPropExists				!CPropVarPtr !(CProp def_ptr)
	| CPredicate				!def_ptr !.[CExpr def_ptr]
instance DummyValue (CProp def_ptr) | DummyValue def_ptr
instance == (CProp def_ptr) | == def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CPropVarDef =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ pvarName					:: !CName
	, pvarInfo					:: !CPropVarInfo
	}
instance DummyValue CPropVarDef

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CPropVarInfo =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  PVar_Nothing 
	| PVar_Fresh				!CPropVarPtr					// always deleted afterwards
	| PVar_Num					!Int
	| PVar_Subst				!CPropH							// always deleted afterwards
instance DummyValue CPropVarInfo

// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CRecordFieldDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ rfName					:: !CName
	, rfIndex					:: !Int							// index in record type
	, rfRecordType				:: !def_ptr
	, rfSymbolType				:: !CSymbolType def_ptr
	, rfTempTypeVarScope		:: !(Maybe [CTypeVarPtr])		// temporarily holds existential types
	, rfSelectorFun				:: !def_ptr
	, rfUpdaterFun				:: !def_ptr
	}
instance DummyValue (CRecordFieldDef def_ptr) | DummyValue def_ptr
   
// -------------------------------------------------------------------------------------------------------------------------------------------------   
:: CRecordTypeDef def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------   
	{ rtdName					:: !CName
	, rtdArity					:: !CArity                     
	, rtdTypeVarScope			:: ![CTypeVarPtr]
	, rtdFields					:: ![def_ptr]
	, rtdRecordConstructor		:: !def_ptr
	, rtdIsDictionary			:: !Bool
	, rtdClassDef				:: !def_ptr
	}
instance DummyValue (CRecordTypeDef def_ptr) | DummyValue def_ptr

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CShared =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ shName					:: !CName
	, shExpr					:: !CExprH
	, shPassed					:: !Bool
	}
instance DummyValue CShared

// =================================================================================================================================================
// All type-variables (except existential ones) must be defined in the scope.
// Use 'getNamedVars' to establish a connection with, for example, the class that the symbol
// type corresponds to (when it is the type of an instantiated member function).
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CSymbolType def_ptr =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ sytTypeVarScope			:: ![CTypeVarPtr]
	, sytArguments				:: !.[CType def_ptr]
	, sytResult					:: !CType def_ptr
	, sytClassRestrictions		:: !.[CClassRestriction def_ptr]
	}
instance DummyValue (CSymbolType def_ptr) | DummyValue def_ptr
      
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CType def_ptr = 
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  CTypeVar					!CTypeVarPtr
	| (==>) infixr 9			!(CType def_ptr) !(CType def_ptr)
	| (@^)  infixr 9			!(CType def_ptr) !.[CType def_ptr]
	| (@@^) infixr 9			!def_ptr !.[CType def_ptr]
	| CBasicType				!CBasicType
	| CStrict					!(CType def_ptr)
	| CUnTypable                                                // needed for dictionaries
instance DummyValue (CType def_ptr) | DummyValue def_ptr
instance == (CType def_ptr) | == def_ptr
instance < (CType def_ptr)
               
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CTypeVarDef =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	{ tvarName					:: !CName
	, tvarInfo					:: !CTypeVarInfo
	}
instance DummyValue CTypeVarDef

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CTypeVarInfo =
// -------------------------------------------------------------------------------------------------------------------------------------------------
	  TVar_Nothing 
	| TVar_Fresh				!CTypeVarPtr
	| TVar_Subst				!CTypeH
instance DummyValue CTypeVarInfo

// -------------------------------------------------------------------------------------------------------------------------------------------------
:: CAlgPatternI			:== CAlgPattern			IndexedPtr
:: CAlgTypeDefI			:== CAlgTypeDef			IndexedPtr
:: CBasicPatternI		:== CBasicPattern		IndexedPtr
:: CBasicValueI			:== CBasicValue			IndexedPtr
:: CCasePatternsI		:== CCasePatterns		IndexedPtr
:: CClassDefI			:== CClassDef			IndexedPtr
:: CClassRestrictionI	:== CClassRestriction	IndexedPtr
:: CDataConsDefI		:== CDataConsDef		IndexedPtr
:: CExprI				:== CExpr				IndexedPtr
:: CFunDefI				:== CFunDef				IndexedPtr
:: CInstanceDefI		:== CInstanceDef		IndexedPtr
:: CMemberDefI			:== CMemberDef			IndexedPtr
:: CPropI				:== CProp				IndexedPtr
:: CRecordFieldDefI		:== CRecordFieldDef		IndexedPtr
:: CRecordTypeDefI		:== CRecordTypeDef		IndexedPtr
:: CSymbolTypeI			:== CSymbolType			IndexedPtr
:: CTypeI				:== CType				IndexedPtr

:: CAlgPatternH			:== CAlgPattern			HeapPtr
:: CAlgTypeDefH			:== CAlgTypeDef			HeapPtr
:: CBasicPatternH		:== CBasicPattern		HeapPtr
:: CBasicValueH			:== CBasicValue			HeapPtr
:: CCasePatternsH		:== CCasePatterns		HeapPtr
:: CClassDefH			:== CClassDef			HeapPtr
:: CClassRestrictionH	:== CClassRestriction	HeapPtr
:: CDataConsDefH		:== CDataConsDef		HeapPtr
:: CExprH				:== CExpr				HeapPtr
:: CFunDefH				:== CFunDef				HeapPtr
:: CInstanceDefH		:== CInstanceDef		HeapPtr
:: CMemberDefH			:== CMemberDef			HeapPtr
:: CPropH				:== CProp				HeapPtr
:: CRecordFieldDefH		:== CRecordFieldDef		HeapPtr
:: CRecordTypeDefH		:== CRecordTypeDef		HeapPtr
:: CSymbolTypeH			:== CSymbolType			HeapPtr
:: CTypeH				:== CType				HeapPtr
// -------------------------------------------------------------------------------------------------------------------------------------------------
   
// -------------------------------------------------------------------------------------------------------------------------------------------------
:: ModuleName				:== !String
:: ModuleKey				:== !Int
:: ModulePtr				:== !Ptr CModule

:: CArity					:== !Int
:: CDefIndex				:== !Int
:: CExprVarPtr				:== !Ptr CExprVarDef
:: CIsExistential			:== !Bool
:: CIsStrict				:== !Bool
:: CName					:== !String
:: CPriority				:== !Int
:: CPropVarPtr				:== !Ptr CPropVarDef
:: CSharedPtr				:== !Ptr CShared
:: CTypeVarPtr				:== !Ptr CTypeVarDef

SparkleCreationDate			:== "03-Oct-2003"
SparkleVersion				:== "0.0.4a"
// -------------------------------------------------------------------------------------------------------------------------------------------------   

// -------------------------------------------------------------------------------------------------------------------------------------------------   
HExprVar			:: !CExprVarPtr				-> CExprH
HShared				:: !CSharedPtr				-> CExprH
HCode				:: !String ![String]		-> CExprH
HBottom				::							   CExprH

HPropVar			:: !CPropVarPtr				-> CPropH
HTrue				::							   CPropH
HFalse				::							   CPropH
// -------------------------------------------------------------------------------------------------------------------------------------------------   














functionType		:: [CType a] -> CType a
isInfix				:: !CInfix -> !Bool
isNoInfix			:: !CInfix -> !Bool
isLeftAssociative	:: !CInfix -> !Bool
isRightAssociative	:: !CInfix -> !Bool
getPriority			:: !CInfix -> !Int
ptrKind				:: !HeapPtr -> !DefinitionKind
ptrModule			:: !HeapPtr -> !ModulePtr
zip3				:: [a] [b] [c] -> [(a,b,c)]