Hello,
I’m relatively new to Haskell.
I’m wondering if it exist a tool to graphically represent Haskell code.
Look at the little
graphics at: http://www.haskell.org/arrows/index.html (and following pages) from Ross Paterson.
If found these very useful to understand the Arrow monad.
Why not automatise this in a tool? Such a tool could draw a graphic from the code of a program.
This could be done entirely automatically from the types of the functions.
Let’s try to do it on a simple example, as an exercise:
f = Map (+1)
How does this function could be represented?
It contains the (+) function.
This function has the type (+) :: Num a => a -> a -> a.
From this type we could deduce the graphic:
Or a curried version:
The function (+1) then is:
The function map could be drawn like this :
Or like this:
And the entire function map (+1) could be represented as:
Thanks to the advanced type system of Haskell, everything could be deduced from the type signatures.
Such a tool would be recreational and educational.
One could zoom in and out in a program, to display more or less details.
This could help understand a program, globally or locally.
We could even imagine a constructive version of the tool, where the programmer would draw functions from a toolbox, and stick them into the graphic!
Does a tool approaching this already exist? If not, would it be a good project?
Cheers,
Corentin