[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / docs / NOTES.interface
1
2 What gets done when printing an interface
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4
5 Basically, we do three things:
6
7 A) Create the import decls. For classes and values, this is easy. We
8    filter the CE and GVE for all exported objects that were not declared 
9    in the module. For types, this is a pain because we may have something
10    which is exported and which refers to a type that isn't. For example,
11    the interface
12    interface C where
13    ...
14    f :: A -> B
15    may export B, but A may be expected to come from somewhere else when
16    C is imported. So, we have to go through all envs which have ranges that
17    may refer to a type. This means the TCE, CE (the class op types), 
18    GIE_inst (instance types) and GVE (types in the sigs). AND we have to
19    filter out prelude defined types from the resulting list.
20
21    Finally, we print the import decls, using the conventions that the renamer
22    expects (no explicit constructors/ class ops, etc.)
23
24 B) Print the fixity decls for whatever constructors/ functions are exported
25
26 C) Print the rest of the decls needed. 
27         1) Type decls - contents of TCE with export flags
28         2) Class decls - contents of CE with export flags
29         3) Instance decls - contents of GIE_inst that refer to either
30                             an exported type or an exported class
31                             (filter then print)
32         4) Value decls - contents of GVE which are not constructors and
33                          which have an export flag
34
35 Issues
36 ~~~~~~
37
38 Type synonyms - to expand or not? Let's not, and complain if a type sig. is
39                 used but not defined
40
41 Canonical form for interfaces - to get rid of perl post-processing!
42
43 Deriving for an abstract data type - shall we worry about this now or later?
44
45 Printing issues
46 ~~~~~~~~~~~~~~~
47
48 It's convenient to make all ranges of environments know how to print themselves
49 (they do now) and decide whether to do so by looking at the export flag
50 in their Name fields. Presumably the constructors of a data type that is
51 exported abstractly will decide not to print themselves, so no special code
52 is needed.
53
54