D.Program depends on D.Simple.Utils

Clemens Fruhwirth clemens at endorphin.org
Thu Aug 23 05:57:42 EDT 2007


I was about to extend Dist.Simple.Utils with a method called
mkSharedLibName, which depends on Compiler information, hence
Dist.Simple.Utils was about to import Dist.Compiler. I ran into this
dependency loop:

Module imports form a cycle for modules:
    imports: <..> Distribution.Program <...>
    imports: <..> Distribution.Simple.Utils <..>
    imports: <..> Distribution.Compiler <..>
make: *** [.depend] Error 1

After a short discussion on #ghc, Esa Ilari Vuokko explained that
Dist.* is not supposed to depend on Dist.Simple.*, so it seems
reasonable to break the dependency cycle at "Program -> Simple.Utils".

Program imports 'die' and two program execution helpers
'rawSystemExit' and 'rawSystemStdout' from Simple.Utils.

Two dependencies on 'die' could be removed easily, 
hunk ./Distribution/Program.hs 192
-    Nothing   -> die ("Cannot find " ++ prog ++ " on the path") $
+    Nothing   -> return EmptyLocation
hunk ./Distribution/Program.hs 213
-    _      -> die ("cannot determine version of " ++ name ++ " :\n" ++ show str)
+    _      -> return prog { programVersion = Nothing }

but the other two uses seems rather ok to me (is it ok to _|_ when an
API is used in an illegal way?), namely:

rawSystemProgram _ prog@(Program { programLocation = EmptyLocation }) _
  = die ("Error: Could not find location for program: " ++ programName prog)

Esa suggested a wider refactoring, namely to remove rawSystemExit and
rawSystemStdout from Program.hs. Esa, you could explain the

Would it be ok to move 'die' and the rawSystem helpers into the Dist.*
hierarchy if this takes longer to resolve?
Fruhwirth Clemens - http://clemens.endorphin.org 

More information about the cabal-devel mailing list