Reorganisation of the source tree
[ghc-hetmet.git] / 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) <br>
104         Rules (CoreUnfold.Unfolding, PprCore.pprTidyIdRules)
105 <p><li>
106         MkId (CoreUnfold.mkUnfolding, Subst, Rules.addRule)
107 <p><li>
108         PrelInfo (MkId)  <br>
109         HscTypes( Rules.RuleBase )
110 </ul></tt>
111
112 <p><li> <strong>That is the end of the infrastructure. Now we get the 
113         main layer of mdoules that perform useful work.</strong>
114
115 <tt><ul>
116 <p><li>
117         CoreTidy (HscTypes.PersistentCompilerState)
118 </ul></tt>
119 </ul>
120
121 HsSyn stuff
122 <ul> 
123 <li> HsPat.hs-boot
124 <li> HsExpr.hs-boot (loop HsPat.LPat)
125 <li> HsTypes (loop HsExpr.HsSplice)
126 <li> HsBinds (HsTypes.LHsType, loop HsPat.LPat, HsExpr.pprFunBind and others)
127      HsLit (HsTypes.SyntaxName)
128 <li> HsPat (HsBinds, HsLit)
129      HsDecls (HsBinds)
130 <li> HsExpr (HsDecls, HsPat)
131 </ul>
132
133
134
135 <h2>Library stuff: base package</h2>
136
137 <ul> 
138 <li> GHC.Base
139 <li> Data.Tuple (GHC.Base), GHC.Ptr (GHC.Base)
140 <li> GHC.Enum (Data.Tuple)
141 <li> GHC.Show (GHC.Enum)
142 <li> GHC.Num (GHC.Show)
143 <li> GHC.ST (GHC.Num), GHC.Real (GHC.Num)
144 <li> GHC.Arr (GHC.ST) GHC.STRef (GHC.ST)
145 <li> GHC.IOBase (GHC.Arr)
146 <li> Data.Bits (GHC.Real)
147 <li> Data.HashTable (Data.Bits, Control.Monad)
148 <li> Data.Typeable (GHC.IOBase, Data.HashTable)
149 <li> GHC.Weak (Data.Typeable, GHC.IOBase)
150 </ul>
151
152
153     <p><small>
154 <!-- hhmts start -->
155 Last modified: Wed Aug 22 16:46:33 GMT Daylight Time 2001
156 <!-- hhmts end -->
157     </small>
158   </body>
159 </html>
160
161
162
163
164