
Hi, I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth. Kind regards, Chris.

I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth.
Hi Chris, Programatica used to have such a thing for the module graph (tools/base/Pfe0Cmds.hs; "graph"), via dot. But for that many modules, the graph is highly likely to be neither pretty nor useful, I'm afraid.. Claus http://en.wikipedia.org/wiki/DOT_language

C.M.Brown
I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth.
For my maths honours thesis, I'll be writing a tool to help people understand the relationships in their Haskell code. I'm hoping to have a visualisation component in there, but that's a relatively low priority. Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.

2008/6/27 Ivan Miljenovic
C.M.Brown
writes: I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth.
For my maths honours thesis, I'll be writing a tool to help people understand the relationships in their Haskell code. I'm hoping to have a visualisation component in there, but that's a relatively low priority.
Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
Just today I wished for something similar for this MATLAB code I'm maintaining... would be good to have a pluggable syntax definition so that it could be easily adapted for use with other languages. Jeremy

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Fri, 27 Jun 2008 15:18:45 +1000
"Jeremy Apthorp"
2008/6/27 Ivan Miljenovic
: C.M.Brown
writes: I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth.
For my maths honours thesis, I'll be writing a tool to help people understand the relationships in their Haskell code. I'm hoping to have a visualisation component in there, but that's a relatively low priority.
Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
Just today I wished for something similar for this MATLAB code I'm maintaining... would be good to have a pluggable syntax definition so that it could be easily adapted for use with other languages.
Technically, what I'm doing is a graph-theoretic analysis framework, with a sample application in which Haskell code is parsed and analysed. Once I get it done, it should be pretty simple to port over to other languages but you'd need to write a parser first (I plan on using Haskell-src and Haskell-src-exts).
Jeremy
- -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkhkgVwACgkQfEfFJ9JhvyiKwwCfaz8WjluQ2rUwD57pmqP15bOn KsUAn3uqbOyGMrEq6nFr71yTyy/mdB7y =+xX9 -----END PGP SIGNATURE-----

Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
I was just recently wondering about something like this. I'd like the ability to show individual module dependencies, and then to collapse modules in one package to just the package, so I could "zoom out" and see how the packages relate to each other. By "package" here I mean the "A" in "A.B, A.C, etc." It seems like it would be fairly simple to use Language.Haskell.Parse to turn a set of modules into a graph, and then something to massage that and give it to dot. It actually brings up a question about module discipline in general: At one point I wanted to have each package re-export its public modules and then sibling packages can only export the "package" module as some libraries do, but it got to be too much re-exporting bookkeeppiing and I didn't so much like symbols having multiple "homes", and most of all it was increasingly awkward to split packages into strictly higher level and strictly lower level relationships since this discipline means coarser granularity which means more trouble avoiding circular imports. So now I just import modules directly from their packages. I still have a general structure of higher, lower, and sibling packages though, so some kind of visualization would be handy to keep deps under control, look for packages and modules that could be split up for a clearer hierarchy, find good places to cut circular imports, etc. I've also thought I could move private modules in A to A.Private, so you can see that if you're importing X.Private.Y from a module that doesn't start with X. then something fishy is going on. How do other people approach this issue?

Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
I'd like the ability to show individual module dependencies, and then to collapse modules in one package to just the package, so I could "zoom out" and see how the packages relate to each other. By "package" here I mean the "A" in "A.B, A.C, etc."
It seems like it would be fairly simple to use Language.Haskell.Parse to turn a set of modules into a graph, and then something to massage that and give it to dot.
If you wanted to go down that route, try using 'ghc --make -v2' and translate that dependency graph to dot. It isn't difficult to produce visualizations (though gathering the data might be - proper dependency analysis in Haskell projects has rated a GSoC project this year, for Cabal). It is difficult to produce *useful* visualizations that *scale* to realistic projects. To begin with, it helps to see the visualization as *input* for software development decisions, not as pretty output for some data traversal. However, the problem is far from new, and it is perhaps not unreasonable to assume that most papers in the area are going to reference this one (so you could start with a reverse reference search, then try to separate the gimmicks from the potentially useful approaches..): Thomas A. Ball and Stephen G. Eick. Software visualization in the large. IEEE Computer, 29(4):33--43, April 1996. http://citeseer.ist.psu.edu/78256.html As far as I can tell, a variety of visualizations is needed in practice, integrated in a single tool suite, with good interactivity/navigation/view switching, so that one can choose the most suitable view and focus/slice for each question one might have about a software project (and change track as new questions arise interactively). It would be great to have such a visualization suite for Haskell projects.. There was Chris Ryder's Medina project (unreleased, web site seems to have disappeared?), which focussed on a metrics library, with some example metrics and visualizations: http://web.archive.org/web/20041229065821/www.cs.kent.ac.uk/people/rpg/cr24/... http://www.cs.kent.ac.uk/pubs/2004/2236/index.html http://www.haskell.org/communities/11-2002/html/report.html#sect4.5.1 Hth, Claus

On Fri, Jun 27, 2008 at 11:39 AM, Claus Reinke
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... Cheers, D -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net

try using 'ghc --make -v2' and translate that dependency graph to dot.
"ghc -M $main.hs" works quite well
hmake -M Main.hs gives much the same output as ghc -M, but without side-effecting your Makefile. Even better, hmake -g Main.hs gives the pure module graph dependencies without the .hs/.o clutter. Caveat: You may need some extra commandline flags like -package base, since hmake does not add those automatically. Regards, Malcolm

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 [NONREC ModSummary { ms_hs_date = Tue Jun 24 19:25:08 GMT Daylight Time 2008 ms_mod = main:BinTreeDatatype, ms_imps = [Data.Generics] ms_srcimps = [] }, NONREC 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 = [] }, NONREC 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 Claus http://www.haskell.org/ghc/docs/latest/html/users_guide/separate-compilation...

On Fri, Jun 27, 2008 at 12:39 PM, Claus Reinke
Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
I'd like the ability to show individual module dependencies, and then to collapse modules in one package to just the package, so I could "zoom out" and see how the packages relate to each other. By "package" here I mean the "A" in "A.B, A.C, etc."
It seems like it would be fairly simple to use Language.Haskell.Parse to turn a set of modules into a graph, and then something to massage that and give it to dot.
If you wanted to go down that route, try using 'ghc --make -v2' and translate that dependency graph to dot.
Yep, this is a pretty easy route and there is already a tool for doing the translation: ocamldot. Don't be fooled by the name, it works on Makefile's dependency information and in particular works well with the output from ghc. Back in the days (like six years ago) I used it on ghc itself. I also extended it so that different directories were grouped together inside a box to get a better feel for the intended structure of the program. ocamldot can be found here: http://www.research.att.com/~trevor/ocamldot/ I should add that I didn't find the information the least bit helpful so my general recommendation is to try to find some other method to help understanding code. All the best, Josef

Hi Ivan,
Assuming I get it included, is there any features in particular you'd want to see in there? Note that if I do have it produce visualisations, they'll be static images as part of an analysis report rather than being interactive.
I'd basically like to see a graph of the overall struture of a Haskell project: what modules import what, and so forth. This would be useful to show which modules are forming the core of a system say, and which modules are acting on the top layer. Hope that gives some insight... Chris.

On Jun 26, 2008, at 4:17 PM, C.M.Brown wrote:
Hi,
I have approx. 100+ source files and I was wondering if anyone has a tool that would let me see a visual call graph for the source files; i.e. a visual hierarchy of which module is imported by what, and so forth.
Kind regards, Chris.
I suggest that you have a look at HaSlicer, a (visual) Haskell slicing tool available online from http://labdotnet.di.uminho.pt/ HaSlicer/HaSlicer.aspx , developed by Nuno Rodrigues (nfr@di.uminho.pt). Best regards jno

Hi Jno,
I suggest that you have a look at HaSlicer, a (visual) Haskell slicing tool available online from http://labdotnet.di.uminho.pt/ HaSlicer/HaSlicer.aspx , developed by Nuno Rodrigues (nfr@di.uminho.pt).
Oh excellent, yes I'd forgotten about this, thanks. Chris.
participants (10)
-
C.M.Brown
-
Claus Reinke
-
Dougal Stanton
-
Evan Laforge
-
Ivan Lazar Miljenovic
-
Ivan Miljenovic
-
J.N. Oliveira
-
Jeremy Apthorp
-
Josef Svenningsson
-
Malcolm Wallace