You are viewing brokenhut

The Broken Hut
Working my way up to a full-size building
That problem when the ideas come too thick and fast. 
7th-Nov-2006 03:48 am

Does anyone else have this problem? You get yourself into a programming groove and all is going swimmingly, and then suddenly think of some other project you could do as well. And the other project always seems tantalisingly trivial. “I’ll just devote a bit of time to it then I’ll come back to what I’m doing.” Naturally you never come back because — if you finish the distraction — you come up with something else new to do.

It’s quite infuriating. In this case, I was going to make an app for drawing import dependency diagrams for Haskell programs. I think it should be fairly easy.

At the top level I need to store a list of modules which have been processed and whatever still to go. A straighforward depth-first wouldn’t work because modules can be appear in several places. But for each file it seems to be a case of:

  1. Process Haskell code with GHC to delit it. Not relevant for most people but most of my code is literal.
  2. Drop all lines that don’t begin with import.
  3. Drop all hierarchical modules. I’ll just deal with flat modules at the moment; I can just strip off everything with a full stop in the name.
  4. Emit a directed-graph description of the form moduleA -> moduleB.

If I do all of that for each source file and wrap all the contents in the appropriate file format for graphviz, it should be fairly easy to create some nice graph pictures.


On further investigation it appears that the Function Graph Library (FGL) includes bindings for Graphviz. I think this task may have actually tipped over into the annoyingly trivial. But that’s okay, cos we’ve already established that if I did it I would just distract myself from other (already started) projects.

Another look at the documentation for the Glorious Haskell Compiler reveals that it should be easy to create a list of user-defined modules, using:

ghc -M Main.lhs

The -M flag makes it spit out a makefile-style dependency list. This is even simpler to splice up and pull out the relevant data, since all the delitting and import command isolation work has been done.

It’s nice when all the work is done for you, isn’t it? We’re sliding steadily towards “temptingly easy” now. I better watch myself…

Comments 
7th-Nov-2006 05:15 am (UTC)
You get yourself into a programming groove and all is going swimmingly, and then suddenly think of some other project you could do as well. And the other project always seems tantalisingly trivial.


That's exactly what I'm feeling these days...
7th-Nov-2006 01:32 pm (UTC)
yeah....i just don't *get* programming.
7th-Nov-2006 03:01 pm (UTC)

What don't you understand about it? The abstractions; the chain of procedures to get a result; how a result is related to specific commands; how the commands relate to the operating system or to the bare metal? Any of this remotely close to what you feel confused about?

I'm probably barking up the wrong tree here, eh? I'll maybe write about it at some point... cos obviously I don't have enough half-finished blog posts hanging around to be getting on with!

7th-Nov-2006 07:12 pm (UTC)
I was gonna write something that used reflection to create graphviz representations of Java class hierarchies, it's a quite neat little problem.

As with most stuff I look at, I think it's more fun to think about than to actually do, though.
This page was loaded Aug 2nd 2014, 12:21 am GMT.