Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
GraphRewriting
Description
This is a monadic graph rewriting library for port graphs with a strong emphasis on nodes. It aims primarily at making it as convenient as possible to specify graph rewriting systems in Haskell and to experiment with them. There are a few aspects of the design to be pointed out:
- The port graph is actually a hypergraph, therefore if we speak of edges we are in fact referring hyperedges.
- The graph structure is essentially representated as a collection of nodes. The nodes have a user-defined type, where each node features a list of
Port
s to each of which anEdge
is attached. Edges are unlabeled and can not exist autonomously, i.e. each edge is connected to at least one port. Each port is connetected to exactly one edge. Two ports are connected if (and only if) they share the same edge. What is particularly convenient is how these ports can be modeled as constructor fields of a user-defined node type. - An important abstraction used in this library is the multi-parameter type-class
View
. It permits to expose a certain aspect of a node, allowing both toinspect
orupdate
it, while hiding the internal representation of the node. By that it is easy to specify the rewrite system in a way, that it can not only be applied to a graph with nodes of a fixed node type, but also to aGraph
with polymorphic node typen
. The nodes merely have to expose values of typev
by means of defining aView v
onn
. TheView
abstraction is also used to expose the nodes' ports (and therefore the graph structure) to this library. - Rewrite
Rule
are represented asPattern
s that return aRewrite
. APattern
is a branching scrutinisation of the graph that returns a result for every possible matching position in the graph. ARule
is essentially aPattern
that returns aRewrite
. ARewrite
is a monadic modification of the graph structure. In aRule
theRewrite
part can conveniently use the variables bound in thePattern
code.
See the graph-rewriting-ski package for an example of a simple rewrite system. Together with the graph-rewriting-layout and the graph-rewriting-gl packages it is easy to build a graphical and interactive application to experiment with your rewrite system.
What the library does not (yet) offer combinators to define strategies, since the emphasis of the project was to create an interactive graph-rewriting tool where rules and rewriting positions are selected manually.
Synopsis
- module GraphRewriting.Graph.Types
- module GraphRewriting.Graph
- module GraphRewriting.Graph.Read
- module GraphRewriting.Graph.Write
- module GraphRewriting.Pattern
- module GraphRewriting.Rule
- module Data.View
Documentation
module GraphRewriting.Graph.Types
graph representation, Rewrite
monad
module GraphRewriting.Graph
mapping over nodes, graph creation, applying a Rewrite
module GraphRewriting.Graph.Read
monadic graph scrutinisation
module GraphRewriting.Graph.Write
monadic graph modification
module GraphRewriting.Pattern
branching graph scrutinisation that keeps track of scrutinised nodes
module GraphRewriting.Rule
module Data.View