From: simonpj@microsoft.com Date: Fri, 4 Jan 2008 12:19:39 +0000 (+0000) Subject: Document SOURCE pragma; clarify TH behavior for mutually-recurive modules (Trac ... X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=f8697474dee10b95bd7cb576a26ce8116aee261b Document SOURCE pragma; clarify TH behavior for mutually-recurive modules (Trac #1012) --- diff --git a/docs/users_guide/glasgow_exts.xml b/docs/users_guide/glasgow_exts.xml index de69b60..26fff9a 100644 --- a/docs/users_guide/glasgow_exts.xml +++ b/docs/users_guide/glasgow_exts.xml @@ -5000,9 +5000,13 @@ Type splices are not implemented, and neither are pattern splices or quotations. - Furthermore, you can only run a function at compile time if it is imported + You can only run a function at compile time if it is imported from another module that is not part of a mutually-recursive group of modules - that includes the module currently being compiled. For example, when compiling module A, + that includes the module currently being compiled. Furthermore, all of the modules of + the mutually-recursive group must be reachable by non-SOURCE imports from the module where the + splice is to be run. + + For example, when compiling module A, you can only run Template Haskell functions imported from B if B does not import A (directly or indirectly). The reason should be clear: to run B we must compile and run A, but we are currently type-checking A. @@ -6374,14 +6378,14 @@ data T = T {-# UNPACK #-} !(Int,Int) will store the two Ints directly in the T constructor, by flattening the pair. - Multi-level unpacking is also supported: + Multi-level unpacking is also supported: data T = T {-# UNPACK #-} !S data S = S {-# UNPACK #-} !Int {-# UNPACK #-} !Int - will store two unboxed Int#s + will store two unboxed Int#s directly in the T constructor. The unpacker can see through newtypes, too. @@ -6395,6 +6399,15 @@ data S = S {-# UNPACK #-} !Int {-# UNPACK #-} !Int constructor field. + + SOURCE pragma + + SOURCE + The {-# SOURCE #-} pragma is used only in import declarations, + to break a module loop. It is described in detail in . + + + diff --git a/docs/users_guide/separate_compilation.xml b/docs/users_guide/separate_compilation.xml index fc22fbd..1bdb0c5 100644 --- a/docs/users_guide/separate_compilation.xml +++ b/docs/users_guide/separate_compilation.xml @@ -702,7 +702,10 @@ 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 +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: