a23d05303e8a3cab23101c4003d39aa9c3f8df23
[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         TypeRep (loop DataCon.DataCon, loop Subst.substTyWith)
67 <p><li>
68         Type (loop PprType.pprType, loop Subst.substTyWith)
69 <p><li>
70         FieldLabel(Type) <br> 
71         TysPrim(Type) <br> 
72 <p><li>
73         Literal (TysPrim, PprType) <br> 
74         DataCon (loop PprType, loop Subst.substTyWith, FieldLabel.FieldLabel)
75 <p><li>
76         TysWiredIn (loop MkId.mkDataConIds)
77 <p><li>
78         TcType( lots of TysWiredIn stuff)
79 <p><li>
80         PprType( lots of TcType stuff )
81 <p><li>
82         PrimOp (PprType, TysWiredIn)
83 <p><li>
84         CoreSyn [does not import Id]
85 <p><li>
86         IdInfo (CoreSyn.Unfolding, CoreSyn.CoreRules)
87 <p><li>
88         Id (lots from IdInfo)
89 <p><li>
90         CoreFVs <br>
91         PprCore
92 <p><li>
93         CoreUtils (PprCore.pprCoreExpr, CoreFVs.exprFreeVars,
94                    CoreSyn.isEvaldUnfolding CoreSyn.maybeUnfoldingTemplate)
95 <p><li> 
96         CoreLint( CoreUtils ) <br>
97         OccurAnal (CoreUtils.exprIsTrivial) <br>
98         CoreTidy (CoreUtils.exprArity ) <br>
99 <p><li>
100         CoreUnfold (OccurAnal.occurAnalyseGlobalExpr)
101 <p><li>
102         Subst (CoreUnfold.Unfolding, CoreFVs)  <br>
103         Generics (CoreUnfold.mkTopUnfolding)
104 <p><li>
105         Rules (CoreUnfold.Unfolding, PprCore.pprTidyIdRules)
106 <p><li>
107         MkId (CoreUnfold.mkUnfolding, Subst, Rules.addRule)
108 <p><li>
109         PrelInfo (MkId)  <br>
110         HscTypes( Rules.RuleBase )
111 </ul></tt>
112
113 <p><li> <strong>That is the end of the infrastructure. Now we get the 
114         main layer of mdoules that perform useful work.</strong>
115
116 <tt><ul>
117 <p><li>
118         CoreTidy (HscTypes.PersistentCompilerState)
119 </ul></tt>
120 </ul>
121
122 HsSyn stuff
123 <ul> 
124 <li> HsPat.hs-boot
125 <li> HsExpr.hs-boot (loop HsPat.LPat)
126 <li> HsTypes (loop HsExpr.HsSplice)
127 <li> HsBinds (HsTypes.LHsType, loop HsPat.LPat, HsExpr.pprFunBind and others)
128      HsLit (HsTypes.SyntaxName)
129 <li> HsPat (HsBinds, HsLit)
130      HsDecls (HsBinds)
131 <li> HsExpr (HsDecls, HsPat)
132 </ul>
133
134
135     <p><small>
136 <!-- hhmts start -->
137 Last modified: Wed Aug 22 16:46:33 GMT Daylight Time 2001
138 <!-- hhmts end -->
139     </small>
140   </body>
141 </html>
142
143
144
145
146