1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
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>
8 <body BGCOLOR="FFFFFF">
9 <h1>The GHC Commentary - The Marvellous Module Structure of GHC </h1>
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.
17 This section of the commentary documents the subtlest part of
18 the module dependency graph, namely the part near the bottom.
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
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>.
31 Compilation order is as follows:
34 <strong>First comes a layer of modules that have few interdependencies,
35 and which implement very basic data types</strong>:
48 <li> <strong> Now comes the main subtle layer, involving types, classes, type constructors
49 identifiers, expressions, rules, and their operations.</strong>
53 <li> Name <br> PrimRep
57 Var (Name, loop IdInfo.IdInfo,
58 loop Type.Type, loop Type.Kind)
60 VarEnv, VarSet, ThinAir
62 Class (loop TyCon.TyCon, loop Type.Type)
64 TyCon (loop Type.Type, loop Type.Kind, loop DataCon.DataCon, loop Generics.GenInfo)
66 Type (loop DataCon.DataCon, loop Subst.substTy)
71 Literal (TysPrim, PprType) <br>
72 DataCon (loop PprType, loop Subst.substTyWith, FieldLabel.FieldLabel)
74 TysWiredIn (loop MkId.mkDataConWorkId, loop Generics.mkGenInfo, DataCon.mkDataCon)
76 TcType( lots of TysWiredIn stuff)
78 PprType( lots of TcType stuff )
80 PrimOp (PprType, TysWiredIn)
82 CoreSyn [does not import Id]
84 IdInfo (CoreSyn.Unfolding, CoreSyn.CoreRules)
91 CoreUtils (PprCore.pprCoreExpr, CoreFVs.exprFreeVars,
92 CoreSyn.isEvaldUnfolding CoreSyn.maybeUnfoldingTemplate)
94 CoreLint( CoreUtils ) <br>
95 OccurAnal (CoreUtils.exprIsTrivial) <br>
96 CoreTidy (CoreUtils.exprArity ) <br>
98 CoreUnfold (OccurAnal.occurAnalyseGlobalExpr)
100 Subst (CoreUnfold.Unfolding, CoreFVs) <br>
101 Generics (CoreUnfold.mkTopUnfolding)
103 Rules (CoreUnfold.Unfolding, PprCore.pprTidyIdRules)
105 MkId (CoreUnfold.mkUnfolding, Subst, Rules.addRule)
108 HscTypes( Rules.RuleBase )
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>
116 CoreTidy (HscTypes.PersistentCompilerState)
126 Last modified: Wed Aug 22 16:46:33 GMT Daylight Time 2001