Discovery of source dependencies without --make
Lars Hupel
lars at hupel.info
Fri Nov 28 14:41:44 UTC 2014
> Rather than explain by deltas from something else, it might be
> easier just to write down precisely what you seek.
Let's say the hypothetical feature is selected via the GHC flag
"--topo-sort". It would add a step before regular compilation and
wouldn't affect any other flag:
ghc -c --topo-sort fileA.hs fileB.hs ...
This would first read in the specified source files and look at their
module headers and import statements. It would build a graph of module
dependencies _between_ the specified source files (ignoring circular
dependencies), perform a topological sort on that graph, and proceed
with compiling the source files in that order.
As a consequence, if there is an order in which these modules can be
successfully compiled, "--topo-sort" would choose such an order. In that
sense, the above invocation would be equivalent to
ghc -c fileB.hs fileA.hs ...
(using some permutation of the original order specified)
Another consequence is that any invocation of GHC in the form of
ghc -c flags... sources.hs...
with arbitrary flags would still work as usual when adding "--topo-sort".
Quoting from the user manual:
> In your program, you import a module Foo by saying import Foo. In
> --make mode or GHCi, GHC will look for a source file for Foo and
> arrange to compile it first. Without --make, GHC will look for the
> interface file for Foo, which should have been created by an earlier
> compilation of Foo.
The hypothetical "--topo-sort" flag would behave in the latter way, i.e.
it would not require a source file for an unknown dependency. Hence,
"--topo-sort" and "--make" would be conflicting options.
I hope that clears up things a bit.
Cheers
Lars
More information about the Glasgow-haskell-users
mailing list