X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=docs%2Fusers_guide%2Fseparate_compilation.xml;h=1bdb0c5344d716cf7ef2410950a16c8f1d514c0c;hb=a385f0af5ea320a18d580f6a36c59c55b3516efd;hp=934deb17e4d267d9a950c0fb9741d4f2e205b679;hpb=70d12d0e3df4e262aa48bd89987f1f263dedbc2c;p=ghc-hetmet.git diff --git a/docs/users_guide/separate_compilation.xml b/docs/users_guide/separate_compilation.xml index 934deb1..1bdb0c5 100644 --- a/docs/users_guide/separate_compilation.xml +++ b/docs/users_guide/separate_compilation.xml @@ -184,7 +184,7 @@ dots replaced by the directory separator ('/' or '\', depending on the system), and extension is a source extension (hs, lhs) - if we are in mode and GHCi, or + if we are in mode or GHCi, or hisuf otherwise. For example, suppose the search path contains directories @@ -220,7 +220,7 @@ This isn't the whole story: GHC also looks for modules in pre-compiled libraries, known as packages. See the section on - packages (), for details. + packages () for details. @@ -436,7 +436,9 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch` + , + @@ -451,7 +453,9 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch` + , + @@ -461,7 +465,9 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch` + , + @@ -589,9 +595,9 @@ $ ghc -c parse/Foo.hs parse/Bar.hs gurgle/Bumble.hs -odir `arch` - Where file is the name of + where file is the name of an interface file, dumps the contents of that interface in - a human-readable (ish) format. + a human-readable (ish) format. See . @@ -696,8 +702,11 @@ module B where hi-boot files Here A imports B, but B imports A with a {-# SOURCE #-} pragma, which breaks the -circular dependency. For every module A.hs that is {-# SOURCE #-}-imported -in this way there must exist a souce file A.hs-boot. This file contains an abbreviated +circular dependency. Every loop in the module import graph must be broken by a {-# SOURCE #-} import; +or, equivalently, the module import graph must be acyclic if {-# SOURCE #-} imports are ignored. + +For every module A.hs that is {-# SOURCE #-}-imported +in this way there must exist a source file A.hs-boot. This file contains an abbreviated version of A.hs, thus: module A where @@ -706,7 +715,7 @@ module A where To compile these three files, issue the following commands: - ghc -c A.hs-boot -- Poduces A.hi-boot, A.o-boot + ghc -c A.hs-boot -- Produces A.hi-boot, A.o-boot ghc -c B.hs -- Consumes A.hi-boot, produces B.hi, B.o ghc -c A.hs -- Consumes B.hi, produces A.hi, A.o ghc -o foo A.o B.o -- Linking the program @@ -772,7 +781,7 @@ When a hs-boot file A.hs-boot A module M that is {-# SOURCE #-}-imported in a program will usually also be ordinarily imported elsewhere. If not, ghc --make - automatically adds M to the set of moudles it tries to + automatically adds M to the set of modules it tries to compile and link, to ensure that M's implementation is included in the final program. @@ -818,7 +827,7 @@ can be given abstractly, by omitting the '=' sign and everything that follows. data R (x :: * -> *) y -You cannot use deriving on a data type declaration; write in +You cannot use deriving on a data type declaration; write an instance declaration instead. Class declarations is exactly as in Haskell, except that you may not put @@ -1016,6 +1025,15 @@ ghc -M -optdep-f -optdep.depend ... + + + Display a list of the cycles in the module graph. This is + useful when trying to eliminate such cycles. You do not need the -optdep prefix + for this flag. + + + + Turn off warnings about interface file shadowing. @@ -1025,7 +1043,7 @@ ghc -M -optdep-f -optdep.depend ... - Print a full list of the module depenencies to stdout. + Print a full list of the module dependencies to stdout. (This is the standard verbosity flag, so the list will also be displayed with and ; @@ -1169,8 +1187,31 @@ and GHC has no other reason for visiting the module. Example: class C a where ... Here, neither D nor T is declared in module Orphan. -We call such modules ``orphan modules'', -defined thus: +We call such modules “orphan modules”. +GHC identifies orphan modules, and visits the interface file of +every orphan module below the module being compiled. This is usually +wasted work, but there is no avoiding it. You should therefore do +your best to have as few orphan modules as possible. + + +Functional dependencies complicate matters. Suppose we have: + + module B where + instance E T Int where ... + data T = ... + +Is this an orphan module? Apparently not, because T +is declared in the same module. But suppose class E had a +functional dependency: + + module Lib where + class E x y | y -> x where ... + +Then in some importing module M, the constraint (E a Int) should be "improved" by setting +a = Int, even though there is no explicit mention +of T in M. + +These considerations lead to the following definition of an orphan module: An orphan module orphan module @@ -1178,12 +1219,21 @@ defined thus: least one orphan rule. An instance declaration in a module M is an orphan instance if - orphan instance - none of the type constructors - or classes mentioned in the instance head (the part after the ``=>'') are declared - in M. - - Only the instance head counts. In the example above, it is not good enough for C's declaration + orphan instance + + + The class of the instance declaration is not declared in M, and + + + Either the class has no functional dependencies, and none of the type constructors + in the instance head is declared in M; or there + is a functional dependency for which none of the type constructors mentioned + in the non-determined part of the instance head is defined in M. + + + + Only the instance head (the part after the “=>”) + counts. In the example above, it is not good enough for C's declaration to be in module A; it must be the declaration of D or T. @@ -1195,17 +1245,12 @@ defined thus: - GHC identifies orphan modules, and visits the interface file of -every orphan module below the module being compiled. This is usually -wasted work, but there is no avoiding it. You should therefore do -your best to have as few orphan modules as possible. - - - You can identify an orphan module by looking in its interface +GHC will warn you if you are creating an orphan module, if you add `-fwarn-orphan-modules`. +You can identify an orphan module by looking in its interface file, M.hi, using the -. If there is a ``!'' on the first line, -GHC considers it an orphan module. + mode. If there is a [orphan module] on the +first line, GHC considers it an orphan module.