#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 |
------------------------------+---------------------------------------------
Comment (by fons):
Replying to [comment:11 simonpj]:
> 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 finally managed to solve the problem "turning around" the circular
dependencies of my project (tranforming the SOURCE imports of the loop in
normal onces and vice versa). However, the workaround suggested by Simon
should work as you said.
> Meanwhile I'll close the bug.
As far as I understand, ghc's dependency analysis could be improved
(otherwise a workaround would not be needed). I don't personally think
this bug should be closed and include it as a limitation in the docs
before considering simonmar's proposal, that is:
''What's happening is that the dependency analysis isn't figuring out that
the real ModuleA must be compiled before ModuleB. I think the solution is
something along the lines of: every module that depends on a module in a
cycle, but is not a member of that cycle, should have an implicit
dependency on each of the modules in the cycle. ''
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/1012#comment:12>
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