summaryrefslogtreecommitdiff
path: root/ghc/docs/NOTES.import
blob: 30e65c4221a6fb5556e94f0d6c0fdec74cc179b6 (plain)
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
		Notes on imports
		~~~~~~~~~~~~~~~~
		SLPJ 15 March 91


Distinguish three kinds of things in interfaces:

	- type, data, class, instance, value decls at top level

	- the same but imported.  Syntax
		import B renaming C to D where
			data C = ...

	- imports, which serve just to attach original names
		import B(X,Y)


The third group are syntactically stuck at the beginning; the second two
can be intermingled.

Pass 1
~~~~~~
Process each imported interface, and the implementation being compiled,
scanning *headers of*

	type, data and class decls (incl imported ones in interfaces)

giving the following environments for each

	type/data info	{(ModStr,TyConStr) -> arity}
	class info	{(ModStr,ClassStr)}

These are filtered (*but not renamed*) by the imports specified in the
impl (ignore dotdot parts and parts in parens), to give a grand
environment E1 of the same shape.  It gives the original names of in-scope
types and classes.

Pass 2
~~~~~~
Process each imported interface and the implementation being compiled:
	
	- scan its imports and use them to filter and rename E1, to give

			{TyConStr -> arity}
			{ClassStr}

	- scan type, data, class decls, headers of instance decls
	  and value type sigs in interfaces

giving for each:

	class info (CE)		{ClassStr -> (ClassId, [ClassOpStr])}
	inst info (GIE)		{(ClassId,TyConId) -> (Context, GlobalId)}
		(info from both class and instance decls)

	type/data info (TCE)	{TyConStr -> (TyConId, [ConstrStr])}


	value info (GVE)	{ValStr -> GlobalId}
		(info from value sigs, and constructors from data decls)

Filter and rename the environments gotten from each import to make a grand
environment E2. 

Pass 3
~~~~~~
Check E2 for class cycles, and type synonym cycles.

Pass 4
~~~~~~
Process the value decls in the impl, giving {ValStr -> GlobalId}, and some
code.

Pass 5
~~~~~~
Process the bodies of instance decls, to generate code for methods.






		UNRESOLVED
		~~~~~~~~~~
1. Who generates the interface?

2. Where is dependency analysis done?