Discovery of source dependencies without --make

Lars Hupel lars at hupel.info
Thu Nov 27 10:31:55 UTC 2014


> The only problem I see with that is that error message locations will be
> a bit off, since the file being compiled is different from the file
> submitted. But since we're in the hacks territory anyway, this could be
> fixed up with a simple regex :-)

... or line pragmas :-)

I'm currently investigating another route though. I wrote a simple
program which parses some Haskell files with "haskell-src-exts" (we
actually even need "hse-cpp"), builds a graph with all known
dependencies, uses "topSort" from "Data.Graph" to come up with a proper
ordering and prints the source files in that order. That approach feels
a lot safer to me. It can be used like:

  ghc -c $(cabal exec topoSort "${files[@]}")

(Never mind the obvious unsafe file name handling.)

The downside is that parse errors won't be reported by GHC, but by our
preprocessing tool.

(I've attached the tool, but keep in mind it's just a quick proof of
concept.)

Cheers
Lars
-------------- next part --------------
A non-text attachment was scrubbed...
Name: HsTopoSort.hs
Type: text/x-haskell
Size: 981 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20141127/2872d1ea/attachment.hs>


More information about the Glasgow-haskell-users mailing list