8

Haskell Arrows are commonly explained as expressing a directed acyclic graph (DAG) of computations. I'm looking for tools or library code that would use this relationship in aid of programming with Arrows.

From Arrow to graph, a tool could help visualize Arrow code. Since the code corresponds to a DAG of computations, a visual representation showing computational nodes and output-to-input edges is natural. A tool could create a graph to be viewed and manipulated with standard graph tools.

Is there Arrow transformer that augments an arbitrary compuatational Arrow class, capturing the structure provided by >>> and *** operations, and making it possible to inspect the computation as a graph of elementary Arrow operations?

From graph to Arrow, suppose there is a DAG whose nodes are Arrow operations. Is there a tool that would construct from this an Arrow which computes the entire DAG?

I've Googled much of what's written about Haskell Arrows without finding such visualization tools. Did I miss something? Perhaps there is not as natural a fit as I expect.

pkturner
  • 83
  • 4
  • Still hoping for a response that helps with a "graph to Arrow" tool. I'm beginning to understand that when the elementary Arrows have tuple types, then the graph needs to be more expressive than a simple DAG, in order to identify which output goes to which input. Is there a name or a theory for such graphs? – pkturner Feb 24 '14 at 11:34
  • I can't tell exactly what you're asking with regard to "graph to Arrow", but if you have a type that represents a DAG whose nodes are Arrow operations, it sounds like you can just give that type an Arrow instance and be done. – Tom Ellis Feb 24 '14 at 14:56
  • @Tom: It would be that easy if the DAGs don't do anything fancy with tuple types. I had in mind for example ![graph of 4 nodes with crisscross of 4 arrows](http://pkturner.org/programming/path4700.png). It looks as if when I fill in details of the more expressive graph type that I need, your suggestion is still workable. – pkturner Feb 25 '14 at 03:05

1 Answers1

8

A good starting point is to specify your arrow graph using what is known as a "Free Arrow". You can find one implementation of free Arrows in this Stack Overflow answer. Think of this as a syntactic representation of your Arrow graph.

The nice thing about free Arrows is that they preserve the structure of the graph, which you can then display as a diagram. After displaying the graph of connections you can then use an interpreter to transform the free Arrow to the desired Arrow. One nice property that free Arrows have is that such an interpreter must be unique (up to isomorphism) by definition (that's one of the properties that makes it "free").

Community
  • 1
  • 1
Gabriella Gonzalez
  • 34,863
  • 3
  • 77
  • 135
  • This is a good answer to the "Arrow to graph" part of my question. Looks better than my "Arrow transformer" idea. – pkturner Feb 24 '14 at 11:28
  • @pkturner I think what you might want is the `Arrows` language extension, which lets you build up an `Arrow` from a bunch of edges. Basically, any time you write `y <- someArrow -< x` it creates an edge between nodes `x` and `y` where the edge is `someArrow`. If that is close to what you had in mind I will add it to my answer. – Gabriella Gonzalez Feb 24 '14 at 15:14
  • That's the kind of thing I was looking for. My ![4 nodes with crisscross of 4 arrows](http://pkturner.org/programming/path4700.png) example can be written (a1,a0) <- (source -< ()) (b1,b0) <- (source -< ()) () <- sink -< (a0,b0) () <- sink -< (a1,b1) BTW where I come from we're calling the elementary Arrow operations nodes, and the connection from output to input edges. – pkturner Feb 25 '14 at 04:23