[Haskell-cafe] ANNOUNCE: Graphalyze-0.4 and SourceGraph-0.2

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Sun Oct 12 09:54:44 EDT 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'd like to announce version 0.4 of my Graphalyze library [1] and 0.2 of my
SourceGraph programme [2].

[1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/Graphalyze
[2] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/SourceGraph

This should fix the bugs reported by Gwern Branwen, Magnus Therning (thanks to
Niklas Broberg for stating the correct version for Haskell-Src-Exts) and
Christopher Hinson.  No really new features are included in this release.  I
was planning on fixing this and releasing it sooner but - to utilise what seems
to be a current meme [3] - "I accidentally my Gentoo" on Tuesday night and only
fixed it yesterday.

[3] http://encyclopediadramatica.com/I_accidentally_X

Since I'm more awake now than I was when I made the initial release, here's a
run-down of what SourceGraph is:

SourceGraph is a programme designed to help you analyse the static complexity
of your Haskell code when represented as a graph.  At the moment, it does the
following (M == for each module, I = for imports, C = the whole codebase):

* Visualise it {M,I,C}
* See a "collapsed" visualisation {M}
* Proposed module/directory layout using two different algorithms {I,C}
* See the "core" visualisation (recursively strip off roots/leaves) {M}
* Calculate the Cyclomatic complexity [4] {M,I,C}
* Root analysis (compare what's exported to what actually is a root) {M,I,C}
* Determine how many components you have, to see if you should split {M,I,C}
* Clique Analysis (find co-recursive functions) {M,C}
* Cycle analysis (non-cliques) {M,I,C}
* Chain detection (e.g. "straight-line" functions/imports) {M,I,C}

[4] http://en.wikipedia.org/wiki/Cyclomatic_complexity

Current limitations:

* An automatic  refactoring tool: SourceGraph gives *you* information on how you
  might want to possibly refactor your code.  It's not smart: it can't tell
  that you've clumped functions foo and bar in the same module because they do
  similar things or because it's a utility module, even though they're not
  related.  For automatic refactoring, see something like HaRe [5].
* SourceGraph ignore's "data-based" functions, i.e. record-functions and
  class/instance declarations, as it's too confusing (IMHO) which actual
  function you mean (if you see "show" being called, is it for Int, Double, or
  something else?).
* Despite using Haskell-Src-Exts, some extensions (e.g. TH) are ignored, mainly
  because I have no idea how they work and nothing to test it on.  GHC
  extensions should be supported (read the parser won't choke on them) though.
* Reporting output is currently rather limited:
  - The report will be generated in a subdirectory called "SourceGraph" of the
    codebase directory; this is currently hardwired in.
  - It will produce an all-in-one html file report, with no fancy CSS magic to
    make it look pretty.  Ideally, it would produce a split-file, and allow you
    to choose output format.
  - Large graphs are shrunk down to being a maximum of 15"x10".  Ideally, I'd
    like to extend this later so that large graphs will have a shrunk version
    in the graph, which link to a larger version (note though that these graphs
    get very large very fast).
  - The output of individual function names, etc. could be improved.

[5] http://www.cs.kent.ac.uk/projects/refactor-fp/hare.html

SourceGraph can be installed with cabal-install.  Once you've done so, you can
analyse a cabalized library/application Foo as follows:

    $ SourceGraph /path/to/codebase/Foo.cabal 
    Report generated at: /path/to/codebase/SourceGraph/Foo.html

This has been written as part of my mathematics Honours Thesis,
"Graph-Theoretic Analysis of the Relationships in Discrete Data".  Since I've
actually got to write the thesis up now, I won't be making any more releases
for a while.  After uni is over for the semester though, I hope to tidy it up
and extend it.

If you want to check the code out yourselves, there's also darcs repositories
for Graphalyze [6] and SourceGraph [7].

[6] http://code.haskell.org/Graphalyze
[7] http://code.haskell.org/SourceGraph/

Note that whilst Graphalyze is fully documented, etc., the internals of
SourceGraph are a bit fugly (mainly due to time constraints).

Enjoy!

- -- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkjyAacACgkQfEfFJ9JhvyiHEACfVVuRk2FR3ZQiJ6H18FFK/de/
sukAn0tuCLwqxmzlQvWicQKQ3qEJKC1K
=HRUK
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list