[Haskell-cafe] ANNOUNCE: SourceGraph-

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Tue Sep 29 04:00:57 EDT 2009

SourceGraph [1] is a tool to statically analyse your Haskell code by
applying graph-theoretic techniques on the call graph.  It utilised the
Graphalyze [2] library to do so, both of which were originally written
as part of my Honours thesis last year [3].

[1] http://hackage.haskell.org/package/SourceGraph
[2] http://hackage.haskell.org/package/Graphalyze
[3] http://ivanmiljenovic.wordpress.com/2008/11/03/graph-theoretic-analysis-of-relationships-within-discrete-data/

I have been meaning to update SourceGraph since last year, but was
waiting for improvements to the graphviz [4] library first.  Now that
these are done and I have fewer excuses, I've started to improve upon

[4] http://hackage.haskell.org/package/graphviz

When I first released SourceGraph last year, several people (e.g. Gwern)
wanted support for CPP and command-line options.  Unfortunately, I
haven't yet gotten around to that; what I have done is added support for
type classes and data structures, something I originally said I wasn't
going to do.  This support isn't perfect, especially when dealing with
type classes from outside the scope of the code base, but in most cases
works (except that the virtual instance functions don't always get
positioned in the correct spots for some reason).  The produced graphs
are now also much prettier, with various colours and shapes being used.

The useful features that SourceGraph offers include:

* Visualisation of each module, the relations between modules and the
  entire code base.

* Finds functions that are exported from a module that isn't in exposed
  in the .cabal file.

* Alternate module splits.

Please note that SourceGraph is _not_ a refactoring tool: it is designed
to give you the programmer more information about what is in your code.

I'd appreciate it if people could give SourceGraph a whirl and at least
check how well the conversion from Haskell code to the graph is, as I'm
not that sure how well I've converted haskel-src-ext's [5] internal
state to SourceGraph's state.  Please note that there are already
various aspects that I know don't work properly; these can be found in
the ParsingProblems.txt file (KnownProblems.txt contains other
non-parsing problems that I'm aware of).  In particular, TH, etc. aren't

[5] http://hackage.haskell.org/package/haskell-src-exts-1.1.4

To use SourceGraph after it's been installed, at a prompt do the

  > SourceGraph path/to/project.cabal

The resulting report will then be found in a directory called
"SourceGraph" in the same directory as the cabal file.

Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com

More information about the Haskell-Cafe mailing list