#1012: ghc panic with mutually recursive modules and template haskell
------------------------------+---------------------------------------------
Reporter: guest | Owner:
Type: bug | Status: closed
Priority: normal | Milestone: 6.8 branch
Component: Template Haskell | Version: 6.8.2
Severity: normal | Resolution: fixed
Keywords: | Difficulty: Unknown
Testcase: TH_import_loop | Architecture: Multiple
Os: Multiple |
------------------------------+---------------------------------------------
Changes (by simonpj):
* status: reopened => closed
* resolution: => fixed
Comment:
Simon is right: B.hs depends on C.hs, which depends on A.hs-boot. I think
it's quite accidental that A happens to be compiled before B in your
"curiously enough" case, but after B in your original case.
All you need do is to make B depend on A, thus
{{{
{-# LANGUAGE TemplateHaskell #-}
module ModuleB where
import ModuleC
import ModuleA
$(nothing)
}}}
and it all works fine. Use -v to see the compilation order.
I will clarify the documentation, thus:
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''. 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.
{{{
Fri Jan 4 12:19:39 GMT 2008 [EMAIL PROTECTED]
* Document SOURCE pragma; clarify TH behavior for
mutually-recurive modules (Trac #1012)
}}}
It's not clear to me how to improve the error message, at least not
without adding more plumbing to say "I'm in a Template Haskell splice".
Let's see if it happens again.
Meanwhile I'll close the bug.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1012#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs