Reputation: 83
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.
Upvotes: 8
Views: 676
Reputation: 35089
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 Arrow
s in this Stack Overflow answer. Think of this as a syntactic representation of your Arrow
graph.
The nice thing about free Arrow
s 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 Arrow
s have is that such an interpreter must be unique (up to isomorphism) by definition (that's one of the properties that makes it "free").
Upvotes: 9