X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=docs%2Fcomm%2Fthe-beast%2Fmodules.html;fp=docs%2Fcomm%2Fthe-beast%2Fmodules.html;h=a6655a68a760aadb745f28af83710e0ea113b24a;hp=0000000000000000000000000000000000000000;hb=0065d5ab628975892cea1ec7303f968c3338cbe1;hpb=28a464a75e14cece5db40f2765a29348273ff2d2 diff --git a/docs/comm/the-beast/modules.html b/docs/comm/the-beast/modules.html new file mode 100644 index 0000000..a6655a6 --- /dev/null +++ b/docs/comm/the-beast/modules.html @@ -0,0 +1,80 @@ + + +
+ +This section describes the datatypes ModuleName
+ Module
and PackageName
all available
+ from the module Module
.
+ +
A package is a collection of (zero or more) Haskell modules, + together with some information about external libraries, extra C + compiler options, and other things that this collection of modules + requires. When using DLLs on windows (or shared libraries on a + Unix system; currently unsupported), a package can consist of only + a single shared library of Haskell code; the reason for this is + described below. + +
Packages are further described in the User's Guide here. + +
At the bottom of the hierarchy is a ModuleName
,
+ which, as its name suggests, is simply the name of a module. It
+ is represented as a Z-encoded FastString, and is an instance of
+ Uniquable
so we can build FiniteMap
s
+ with ModuleName
s as the keys.
+
+
A ModuleName
can be built from a
+ String
, using the mkModuleName
function.
+
+
For a given module, the compiler also needs to know whether the + module is in the home package, or in another package. + This distinction is important for two reasons: + +
When generating code to call a function in another package, + the compiler might have to generate a cross-DLL call, which is + different from an intra-DLL call (hence the restriction that the + code in a package can only reside in a single DLL). + +
We avoid putting version information in an interface file + for entities defined in another package, on the grounds that other + packages are generally "stable". This also helps keep the size of + interface files down. +
The Module
type contains a ModuleName
+ and a PackageInfo
field. The
+ PackageInfo
indicates whether the given
+ Module
comes from the current package or from another
+ package.
+
+
To get the actual package in which a given module resides, you
+ have to read the interface file for that module, which contains
+ the package name (actually the value of the
+ -package-name
flag when that module was built). This
+ information is currently unused inside the compiler, but we might
+ make use of it in the future, especially with the advent of
+ hierarchical modules, to allow the compiler to automatically
+ figure out which packages a program should be linked with, and
+ thus avoid the need to specify -package
options on
+ the command line.
+
+
Module
s are also instances of
+ Uniquable
, and indeed the unique of a
+ Module
is the same as the unique of the underlying
+ ModuleName
.
+
+