Fwd: [Haskell-cafe] Graphical representation of Haskell code

Miguel Vilaca jmvilaca at di.uminho.pt
Wed Mar 24 19:07:10 EDT 2010


Hi all,

Concerning INblobs, it's again online; a fire damaged the cable that links the university to the world!!
I don't update the tool for a long time... but I'll take a look on that.

Concerning visual functional programming, see this small chapter of my thesis about some of the existing languages.


There are more subtleties on the visual side than those expected!!

If you also consider debugging tools, take a look on Ghood http://hackage.haskell.org/package/GHood

best regards
Miguel Vilaça

A 2010/03/23, às 05:31, Ronald Guida escreveu:

> On Mon, Mar 22, 2010 at 7:02 PM, Dupont Corentin
> <corentin.dupont at gmail.com> wrote:
>> Hello, I’m relatively new to Haskell.
>> I’m wondering if it exist a tool to graphically represent Haskell code.
> ...
>> Let’s try to do it on a simple example, as an exercise:
>> f = Map (+1)
> 
> Your graphic for "f = map (+1)" seems much more complex than the
> corresponding code.  I would agree with Ivan Miljenovic:
>> I'm of the opinion that unless you just use it on small snippets,
>> the generated images will be too large and unwieldy.
> 
> The first question I would ask is /why/ would you like to visualize
> some Haskell code?  If you want to see the high-level structure of
> a complex program, try SourceGraph. (I have never used it though.)
> 
> On the other hand, if you are trying to visualize Haskell as part of
> your efforts to learn the language, then I believe it would be best to
> draw diagrams by hand, rather than relying on an automated tool.
> The kinds of things that you'll want to depict are probably going to
> vary considerably, depending on what you're trying to understand.
> 
> Consider a few different implementations of the "map" function:
> 
>  -- version 1: recursion
>  map1 :: (a -> b) -> [a] -> [b]
>  map1 f [] = []
>  map1 f (x:xs) = (f x) : map1 f xs
> 
>  -- version 2: fold
>  map2 :: (a -> b) -> [a] -> [b]
>  map2 f = foldr ((:) . f) []
> 
>  -- version 3: continuation passing style
>  map3 :: (a -> b) -> [a] -> [b]
>  map3 f xs = map' (\x y -> f x : y) xs
>    where
>      map' k [] = []
>      map' k (y:ys) = k y  (map' k ys)
> 
>  -- version 4: list comprehension
>  map4 :: (a -> b) -> [a] -> [b]
>  map4 f xs = [f x | x <- xs]
> 
>  -- version 5: list monad
>  map5 :: (a -> b) -> [a] -> [b]
>  map5 f xs = xs >>= (return . f)
> 
> These all do exactly the same thing, but each one uses different
> techniques.  If I'm trying to learn (or teach) Haskell, I would
> probably need a slightly different visual "language" for each one
> in order to capture the most relevant concepts in a useful way.
> How would you visualize them?
> 
> @Mihai Maruseac:
> I think a visual debugger would be a wonderful idea.  You may want
> to consider how a visual debugger would work with each of these
> versions of map.
> 
> :-) You might also consider several versions of factorial :-)
> http://www.willamette.edu/~fruehr/haskell/evolution.html
> 
> -- Ron
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


-------------- next part --------------
Skipped content of type multipart/mixed


More information about the Haskell-Cafe mailing list