Discovery of source dependencies without --make

Thomas Miedema thomasmiedema at
Mon Dec 14 00:12:39 UTC 2015

On Fri, Nov 28, 2014 at 3:41 PM, Lars Hupel <lars at> wrote:

> 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.

GHC 8 will have support for Frontend plugins. Frontend plugins enable you
to write plugins to replace
GHC major modes.

E.g. instead of saying

    ghc --make A B C

you can now say:

    ghc --frontend TopoSort A B C

You still have to implement TopoSort.hs yourself, using the GHC API to
compile A B C in topological order, but some of the plumbing is taken care
of by the Frontend plugin infrastructure already.

Take a look at this commit, especially the user's guide section and the
test case:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Glasgow-haskell-users mailing list