Showing posts with label visual-graphrewrite. Show all posts
Showing posts with label visual-graphrewrite. Show all posts

Thursday, July 16, 2009

Usable UI

It's been a long and busy time since the last post which involved me getting my Masters degree, but now I'm back to coding.

The README file which is on hackage goes on about a version that is to be released by the end of May, but well, it didn't make it (partly because I didn't want to upload an unusable program full of bugs).

Now I'm concentrating on usability, then I'll get back to bugfixing. Most of the time I'm getting myself familiar with GTK concepts including glade and the gtk2hs bindings, we'll see what evolves from this. Here's a screenshot for now which shows the planned UI for 0.4:


It shows the weak root normal form of an expression which computes prime numbers by the sieve of Eratosthenes. What's important is that there's a
  • menu bar at the top (which is currently a noop but I plan to make it usable)
  • navigation buttons at the top left (these are working, hooray!)
  • a map at the bottom left showing your current position in the rewriting process (this is a tree which should not be upside down, with a blue spot marking the current position)
  • and of course the main view
At the moment only the main view and navigation buttons work flawlessly, I still have some plumbing to do on the others.

Tuesday, June 9, 2009

Visualizing the graphrewrite process behind Haskell

As I have already mentioned in the introduction post, I am currently working on version 0.4 of visual-graphrewrite, which is destined to be a tool to show steps of the graph rewriting process executed when evaluating a particular expression in the context of a Haskell module.

What does this mean (if you are familiar with term/graph rewrite systems, you might as well skip this paragraph)? Each time you write an expression that you want to be evaluated, a slightly complicated process is begun by the runtime system (or interpreter or whatever that's evaluating your code), which is called graph reduction. This process essentially tries to automagically make sense of the expression you have written by using a set of rules (which are, surprisingly, called rewrite rules). These rules basically come from functions defined in the context of your expression and are represented mostly by function definitions in Haskell.
The rewrite process takes your expression and tries to search a matching rule. This means just what you think: it tries to find a function definition that fits the expression. Since rewrite rules come from function definitions, each and every rewrite rule has a right hand side which corresponds to an expression on the right hand side of = in a function definition. So if a matching rule is found, the right hand side of the rule is written in place of your original expression - with the correct actual arguments of course. This is about all that is to a rewrite step. This is then repeated over and over again, until there is no matching rule left, when it is said that the resulting expression is in normal form.

Now this tool tries to visualize these steps by representing the expression with a graph and drawing it on-screen. The ultimate goal is to be able to take any haskell98 module and be able to use it as a context for an arbitrary (but correct) expression to execute the rewriting procedure. This should be able to get a behind-the-scenes peek of what is going on when your functional program is running. It is intended as a demonstration tool for newcomers to the functional world, but it can also be used as a debugging tool, although I admit that I have never debugged anything with it to this day on.

The current version uploaded to hackage is only version 0.3.2 which doesn't actually show the rewrite steps, instead it shows only the right hand sides of rule definitions in a given module (that is, function definitions). There is a README file in the package which goes on lying about some next version released by the end of May but some complications arose (I didn't count with the fact that I had to prepare a paper as well for my degree), so this next version is still in the works, although it looks promising as shown on the right.

If you are interested in the source code (or my thesis which is unfortunately only available in hungarian /yet?/), you should check out the project's github page.

Thanks for reading, I hope to write some more details about the project in the not so distant future, so stay tuned! :)