8d63c53105dd7a9c0611fa0ae2222bcb95d7fcf6
[ghc-hetmet.git] / ghc / docs / comm / genesis / modules.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3   <head>
4     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
5     <title>The GHC Commentary - The Marvellous Module Structure of GHC </title>
6   </head>
7
8   <body BGCOLOR="FFFFFF">
9     <h1>The GHC Commentary - The Marvellous Module Structure of GHC </h1>
10     <p>
11
12 GHC is built out of about 245 Haskell modules.  It can be quite tricky
13 to figure out what the module dependency graph looks like.  It can be
14 important, too, because loops in the module dependency graph need to 
15 be broken carefully using <tt>.hi-boot</tt> interface files.
16 <p>
17 This section of the commentary documents the subtlest part of
18 the module dependency graph, namely the part near the bottom.
19 <ul>
20 <li> The list is given in compilation order: that is,
21 module near the top are more primitive, and are compiled earlier.
22 <li> Each module is listed together with its most critical 
23 dependencies in parentheses; that is, the dependencies that prevent it being
24 compiled earlier.  
25 <li> Modules in the same bullet don't depend on each other.
26 <li> Loops are documented by a dependency such as "<tt>loop Type.Type</tt>".
27 This means tha the module imports <tt>Type.Type</tt>, but module <tt>Type</tt>
28 has not yet been compiled, so the import comes from <tt>Type.hi-boot</tt>.
29 </ul>
30
31 Compilation order is as follows:
32 <ul>
33 <li>
34 <strong>First comes a layer of modules that have few interdependencies,
35 and which implement very basic data types</strong>:
36 <tt> <ul>
37 <li> Util
38 <li> OccName
39 <li> Pretty
40 <li> Outputable
41 <li> StringBuffer
42 <li> ListSetOps
43 <li> Maybes
44 <li> etc
45 </ul> </tt>
46
47 <p> 
48 <li> <strong> Now comes the main subtle layer, involving types, classes, type constructors
49 identifiers, expressions, rules, and their operations.</strong>
50
51 <tt>
52 <ul>
53 <li>    Name <br> PrimRep
54 <p><li>
55         PrelNames
56 <p><li>
57         Var (Name, loop IdInfo.IdInfo, 
58              loop Type.Type, loop Type.Kind)
59 <p><li>
60         VarEnv, VarSet, ThinAir
61 <p><li>
62         Class (loop TyCon.TyCon, loop Type.Type)
63 <p><li>
64         TyCon (loop Type.Type, loop Type.Kind, loop DataCon.DataCon, loop Generics.GenInfo)
65 <p><li>
66         Type (loop DataCon.DataCon, loop Subst.substTy)
67 <p><li>
68         FieldLabel(Type) <br> 
69         TysPrim(Type) <br> 
70 <p><li>
71         Literal (TysPrim, PprType) <br> 
72         DataCon (loop PprType, loop Subst.substTyWith, FieldLabel.FieldLabel)
73 <p><li>
74         TysWiredIn (loop MkId.mkDataConWorkId, loop Generics.mkGenInfo, DataCon.mkDataCon)
75 <p><li>
76         TcType( lots of TysWiredIn stuff)
77 <p><li>
78         PprType( lots of TcType stuff )
79 <p><li>
80         PrimOp (PprType, TysWiredIn)
81 <p><li>
82         CoreSyn [does not import Id]
83 <p><li>
84         IdInfo (CoreSyn.Unfolding, CoreSyn.CoreRules)
85 <p><li>
86         Id (lots from IdInfo)
87 <p><li>
88         CoreFVs <br>
89         PprCore
90 <p><li>
91         CoreUtils (PprCore.pprCoreExpr, CoreFVs.exprFreeVars,
92                    CoreSyn.isEvaldUnfolding CoreSyn.maybeUnfoldingTemplate)
93 <p><li> 
94         CoreLint( CoreUtils ) <br>
95         OccurAnal (CoreUtils.exprIsTrivial) <br>
96         CoreTidy (CoreUtils.exprArity ) <br>
97 <p><li>
98         CoreUnfold (OccurAnal.occurAnalyseGlobalExpr)
99 <p><li>
100         Subst (CoreUnfold.Unfolding, CoreFVs)  <br>
101         Generics (CoreUnfold.mkTopUnfolding)
102 <p><li>
103         Rules (CoreUnfold.Unfolding, PprCore.pprTidyIdRules)
104 <p><li>
105         MkId (CoreUnfold.mkUnfolding, Subst, Rules.addRule)
106 <p><li>
107         PrelInfo (MkId)  <br>
108         HscTypes( Rules.RuleBase )
109 </ul></tt>
110
111 <p><li> <strong>That is the end of the infrastructure. Now we get the 
112         main layer of mdoules that perform useful work.</strong>
113
114 <tt><ul>
115 <p><li>
116         CoreTidy (HscTypes.PersistentCompilerState)
117 </ul></tt>
118 </ul>
119
120
121
122
123
124     <p><small>
125 <!-- hhmts start -->
126 Last modified: Wed Aug 22 16:46:33 GMT Daylight Time 2001
127 <!-- hhmts end -->
128     </small>
129   </body>
130 </html>
131
132
133
134
135