From 7c85c014f3e69d0d39f8d57955193b262f14fe89 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 27 Jun 2002 12:17:48 +0000 Subject: [PATCH] [project @ 2002-06-27 12:17:47 by simonmar] Improve the documentation for hierarchical libraries. --- ghc/docs/users_guide/glasgow_exts.sgml | 40 ++++++++++++------------ ghc/docs/users_guide/separate_compilation.sgml | 37 ++++++++++++++++++++++ ghc/docs/users_guide/using.sgml | 6 ++++ 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/ghc/docs/users_guide/glasgow_exts.sgml b/ghc/docs/users_guide/glasgow_exts.sgml index 012f922..3024254 100644 --- a/ghc/docs/users_guide/glasgow_exts.sgml +++ b/ghc/docs/users_guide/glasgow_exts.sgml @@ -2385,38 +2385,38 @@ Assertion failures can be caught, see the documentation for the it extends the normally flat Haskell module namespace into a more flexible hierarchy of modules. - A module name in the extended syntax consists of a - sequence of components, each separated by a dot. When searching - for an interface file (or a source file, in the case of GHCi or - when using ) for an imported module, GHC - interprets the dot as a path separator. So for example, if a - module A.B.C is imported, then for each - directory D on the search path (see the - option, ), GHC will look in the - directory D/A/BOn Windows, - this would be D\A\B. for an - interface file called C.hi or a source file - C.hs or C.lhs. - - Note that as far as the compiler is concerned, module - names are always fully qualified; the hierarchy only has a - special meaning when searching for interface files and source - files in the filesystem. In particular, this means that the - full module name must be given after the + This extension has very little impact on the language + itself; modules names are always fully + qualified, so you can just think of the fully qualified module + name as the module name. In particular, this + means that the full module name must be given after the module keyword at the beginning of the module; for example, the module A.B.C must begin module A.B.C + + It is a common strategy to use the as + keyword to save some typing when using qualified names with + hierarchical modules. For example: + + +import qualified Control.Monad.ST.Strict as ST + + + Hierarchical modules have an impact on the way that GHC + searches for files. For a description, see . + GHC comes with a large collection of libraries arranged hierarchically; see the accompanying library documentation. There is an ongoing project to create and maintain a stable set of core libraries used by several Haskell compilers, and the libraries that GHC comes with represent the current status of that project. For more details, see . + url="http://www.haskell.org/~simonmar/libraries/libraries.html">Haskell + Libraries. diff --git a/ghc/docs/users_guide/separate_compilation.sgml b/ghc/docs/users_guide/separate_compilation.sgml index 5e0ce6c..a07c3ee 100644 --- a/ghc/docs/users_guide/separate_compilation.sgml +++ b/ghc/docs/users_guide/separate_compilation.sgml @@ -120,6 +120,43 @@ + + Finding interfaces for hierarchical modules + + GHC supports a hierarchical module namespace as an + extension to Haskell 98 (see ). + + A module name in general consists of a sequence of + components separated by dots + (‘.’). When looking for + interface files for a hierarchical module, the compiler turns + the dots into path separators, so for example a module + A.B.C becomes A/B/C (or + A\B\C under Windows). Then each component of + the import directories list is tested in turn; so for example if + the list contains directories + D1 to + Dn, then the compiler + will look for the interface in + D1/A/B/C.hi first, + then D2/A/B/C.hi and + so on. + + Note that it's perfectly reasonable to have a module which + is both a leaf and a branch of the tree. For example, if we + have modules A.B and + A.B.C, then A.B's + interface file will be in A/B.hi and + A.B.C's interface file will be in + A/B/C.hi. + + For GHCi and , the search strategy + for source files is exactly the same, just replace the + .hi suffix in the above description with + .hs or .lhs. + + Other options related to interface files interface files, options diff --git a/ghc/docs/users_guide/using.sgml b/ghc/docs/users_guide/using.sgml index 41c467d..fff6144 100644 --- a/ghc/docs/users_guide/using.sgml +++ b/ghc/docs/users_guide/using.sgml @@ -443,6 +443,12 @@ ghc ––make Main.hs interface file for the module, then GHC will complain. The exception to this rule is for package modules, which may or may not have source files. + + The source files for the program don't all need to be in the + same directory; the option can be used to add + directories to the search path (see ). + -- 1.7.10.4