The Haskell 2010 report says that “modules may be mutually recursive”. However, as we all know, GHC requires hs-boot files to be able to have circular dependencies.
This is one of my major pains while writing Haskell, that I cannot split up my code easily into modules that make sense. I either end up with a way too coarse grained giant tree with artificial separations or with a single module with everything.
I wonder what the implementation challenges for circular modules in GHC are/ would be/ were and if this is something that could/ will ever be solved.
the naive way to handle circular dependencies is to “glue” all the modules together in a big module under the hood. so we lose separate compilation. that means that changing one thing forces a recompilation of everything, and also that compilation is potentially much more memory and compute intensive, since it can’t be done modularly.
hs-boot files are i guess a bit more sophisticated than that, allowing users to manually specify multiple compilation passes that let the topological sort of mutual dependencies be compiled in passes. i imagine one could write an algorithm that attempted to automatically derive such data – but deriving that data would effectively require a “glued compilation pre-pass” which would not be separate compilation either.