Improve error message for mutally recursive modules
When I am trying to compile the following modules:
File: Files.hs
module Files where
import SecMonad
File: Lattice.hs
module Lattice where
File: Ref.hs
module Ref where
import SecMonad
File: Screen.hs
module Screen where
import SecMonad
File: Sec.hs
module Sec where
import Lattice
File: SecLib.hs (OBSERVE HERE THAT THE NAME OF THE
MODULE IS NOT THE SAME AS THE FILE)
module SecMonad where
import Lattice
import Sec
import SecMonad
import Files
import Screen
import Ref
File: SecMonad.hs
module SecMonad where
import Lattice
import Sec
I got the message:
ale@localhost ~/Sec7 $ ghci SecLib.hs -fglasgow-exts
GHCi, version 6.8.1: http://www.haskell.org/ghc/ :? for help
Loading package base ... linking ... done.
[1 of 4] Compiling Lattice ( Lattice.hs, interpreted )
[2 of 4] Compiling Sec ( Sec.hs, interpreted )
[3 of 4] Compiling SecIO ( SecIO.hs, interpreted )
Module imports form a cycle for modules:
main:Resources imports: Files Lattice
main:Files imports: SecMonad SecIO Lattice
main:SecMonad
imports: Resources Ref Screen Files SecMonad SecIO Sec Lattice
main:Ref imports: SecMonad SecIO Sec Lattice Data.IORef
main:Screen imports: SecMonad SecIO Lattice
Failed, modules loaded: SecIO, Lattice, Sec.
*SecIO>
I think that it would be of great help if the compiler can check if the names of the modules match the name of the files. It took me a while to discover the stupid mistake, and I believe that, when you have a large number of mobules, it might be difficult to find this bug. So, a simple check would help a lot in this situation.
That is it!