From: simonpj Date: Tue, 1 Feb 2005 17:49:02 +0000 (+0000) Subject: [project @ 2005-02-01 17:49:02 by simonpj] X-Git-Tag: Initial_conversion_from_CVS_complete~1131 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=fc37fb19ab8e5da817d93659b40f830a36ae9890 [project @ 2005-02-01 17:49:02 by simonpj] Finish docs for hs-boot files; please review! --- diff --git a/ghc/docs/users_guide/separate_compilation.xml b/ghc/docs/users_guide/separate_compilation.xml index cb80aad..17a896c 100644 --- a/ghc/docs/users_guide/separate_compilation.xml +++ b/ghc/docs/users_guide/separate_compilation.xml @@ -653,20 +653,6 @@ version of A.hs, thus: module A where newtype TA = MkTA Int -A hs-boot file is compiled by GHC, just like a hs file: - - ghc -c A.hs-boot - -Just as compiling A.hs produces an -interface file A.hi, and an object file -A.o, so compiling A.hs-boot -produces an interface file -A.hi-boot, and an pseudo-object file -A.o-boot. The interface file -A.hi-boot has exactly the same format as any -other interface file. The pseudo-object file is empty (don't link it!), but it is -very useful when using a Makefile, to record when the A.hi-boot was -last brought up to date. To compile these three files, issue the following commands: @@ -681,26 +667,44 @@ last brought up to date. The file A.hs-boot is a programmer-written source file. It must live in the same directory as its parent source file A.hs. - (Currently, if you use a literate source file A.lhs you must - also use a literate boot file, A.lhs-boot.) + Currently, if you use a literate source file A.lhs you must + also use a literate boot file, A.lhs-boot; and vice versa. - The hi-boot generated by compiling a hs-boot - file is in machine-generated binary format. - You can display its contents with ghc --show-iface. If you - specify a directory for interface files, the flag, then that affects - hi-boot files too.b - - Hs-boot files are written in a subset of Haskell. In particular, the module - exports and imports, and the scoping rules are exactly the same as in Haskell. Hence, to - mention a non-Prelude type or class, you must import it. - - When a hs-boot file A.hs-boot + + A hs-boot file is compiled by GHC, just like a hs file: + + ghc -c A.hs-boot + +When a hs-boot file A.hs-boot is compiled, it is checked for scope and type errors. When its parent module A.hs is compiled, the two are compared, and an error is reported if the two are inconsistent. + Just as compiling A.hs produces an +interface file A.hi, and an object file +A.o, so compiling A.hs-boot +produces an interface file +A.hi-boot, and an pseudo-object file +A.o-boot: + + +The pseudo-object file A.o-boot is empty (don't link it!), but it is +very useful when using a Makefile, to record when the A.hi-boot was +last brought up to date (see ). + + + + The hi-boot generated by compiling a hs-boot + file is in the same machine-generated binary format as any other + GHC-generated interface file (e.g. B.hi). + You can display its contents with ghc --show-iface. If you + specify a directory for interface files, the flag, then that affects + hi-boot files too.b + + + If hs-boot files are considered distinct from their parent source files, and if a {-# SOURCE #-} import is considered to refer to the hs-boot file, then the module import graph must have no cycles. The ghc -M @@ -717,7 +721,10 @@ A hs-boot file need only contain the bare module that imports A recursively. A hs-boot file is written in a subset of Haskell: - The module header, and import statements, are exactly as in Haskell. + The module header (including the export list), and import statements, are exactly as in +Haskell, and so are the scoping rules. + Hence, to mention a non-Prelude type or class, you must import it. + There must be no value declarations, but there can be type signatures for values. For example: @@ -823,16 +830,16 @@ Main.o Main.hc Main.s : Foo.hi Baz.hi # Main imports Foo and Baz doing…nothing. Which is true. Note that the suffix rules are all repeated twice, once for normal Haskell source files, and once for hs-boot - files (see ). + files (see ). - Note the inter-module dependencies at the end of the - Makefile, which take the form + Note also the inter-module dependencies at the end of the + Makefile, which take the form Foo.o Foo.hc Foo.s : Baz.hi # Foo imports Baz - They tell make that if any of + They tell make that if any of Foo.o, Foo.hc or Foo.s have an earlier modification date than Baz.hi, then the out-of-date file must be