[Haskell-cafe] Re: Call Graph Tool?

Claus Reinke claus.reinke at talk21.com
Fri Jun 27 08:53:44 EDT 2008

>> If you wanted to go down that route, try using 'ghc --make -v2'
>> and translate that dependency graph to dot.
> Also, if you want to get a quick 'n dirty list of which of your own
> files depend on which others, "ghc -M $main.hs" works quite well. I've
> had some success in the past shoving this stuff almost directly into
> the graph libraries and out to graphviz. Be warned that it fiddles
> with any file called Makefile in your working directory...

You can redirect the output of -M, but since it appears that
you cannot combine --make with -fno-code, the incantation
you want is probably something like:

    ghc -M -v2 -optdep-f -optdep depend Main.hs

which gives you dependency output in two forms, a module-based
one to stdout (-v2), a file-based one to file depend (-M -f depend):

$ ghc -M -v2 -optdep-f -optdep depend TestGMap.lhs
Glasgow Haskell Compiler, Version 6.9.20080514, for Haskell 98, stage 2 booted by GHC version 6.6.1
Using package config file: C:\ghc\ghc-6.9.20080514\package.conf
wired-in package ghc-prim mapped to ghc-prim-0.1
wired-in package integer mapped to integer-0.1
wired-in package base mapped to base-3.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1
wired-in package template-haskell mapped to template-haskell-2.2
wired-in package ndp not found.
Created temporary directory: C:\DOCUME~1\cr3\LOCALS~1\Temp\/ghc1564_0
*** Chasing dependencies:
Chasing modules from: TestGMap.lhs
*** Literate pre-processor:
Module dependencies
    ModSummary {
       ms_hs_date = Tue Jun 24 19:25:08 GMT Daylight Time 2008
       ms_mod = main:BinTreeDatatype,
       ms_imps = [Data.Generics]
       ms_srcimps = []
    ModSummary {
       ms_hs_date = Tue Jun 24 19:35:32 GMT Daylight Time 2008
       ms_mod = main:GMap,
       ms_imps = [Unsafe.Coerce, Data.Generics, BinTreeDatatype]
       ms_srcimps = []
    ModSummary {
       ms_hs_date = Tue Jun 24 19:24:46 GMT Daylight Time 2008
       ms_mod = main:Main,
       ms_imps = [GMap, BinTreeDatatype]
       ms_srcimps = []
*** Installing new makefile:
*** Deleting temp files:
*** Deleting temp dirs:

$ cat depend
# DO NOT DELETE: Beginning of Haskell dependencies
BinTreeDatatype.o : BinTreeDatatype.hs
GMap.o : GMap.hs
GMap.o : BinTreeDatatype.hi
TestGMap.o : TestGMap.lhs
TestGMap.o : GMap.hi
TestGMap.o : BinTreeDatatype.hi
# DO NOT DELETE: End of Haskell dependencies



More information about the Haskell-Cafe mailing list