Module Grappa

This module defines the basic data structures for representing graphs and hypergraphs and the corresponding graph parsers.

Summary of exported operations:

getSemRep :: (a,[(b,[Int])]) -> a   
Access the semantic representation of the result of a graph parser.
pSucceed :: a -> [(b,[Int])] -> (a,[(b,[Int])])   
Given an arbitrary value v, pSucceed always succeeds returning v as a result without any consumption of the input graph g.
eoi :: [(a,[Int])] -> ((),[(a,[Int])])   
eoi succeeds only if the graph is already completely consumed.
edge :: (a,[Int]) -> [(a,[Int])] -> ((),[(a,[Int])])   
The parser edge e succeeds only if the given edge e is part of the given input graph g.
(<|>) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (b,[(a,[Int])])) -> [(a,[Int])] -> (b,[(a,[Int])])   
The choice between two parsers.
(<*>) :: ([(a,[Int])] -> (b -> c,[(a,[Int])])) -> ([(a,[Int])] -> (b,[(a,[Int])])) -> [(a,[Int])] -> (c,[(a,[Int])])   
The successive application of two parsers where the result is constructed by function application.
(<$>) :: (a -> b) -> ([(c,[Int])] -> (a,[(c,[Int])])) -> [(c,[Int])] -> (b,[(c,[Int])])   
(<$) :: a -> ([(b,[Int])] -> (c,[(b,[Int])])) -> [(b,[Int])] -> (a,[(b,[Int])])   
(<*) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (c,[(a,[Int])])) -> [(a,[Int])] -> (b,[(a,[Int])])   
(*>) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (c,[(a,[Int])])) -> [(a,[Int])] -> (c,[(a,[Int])])   
chain :: ((Int,Int) -> [(a,[Int])] -> (b,[(a,[Int])])) -> (Int,Int) -> [(a,[Int])] -> ([b],[(a,[Int])])   
The combinator chain p (n1,n2) can be used to identify a non-empty chain of graphs that can be parsed with p.

Exported datatypes:


Node

All nodes are numbered.

Type synonym: Node = Int


Edge

A type for the edge labels t can be passed as a type parameter. In the simplest case this can be just strings representing their labels. The tentacle numbers correspond to the position of a node in the list of incident nodes.

Type synonym: Edge a = (a,[Node])


Graph

A graph is declared as a list of edges each with its incident nodes

Type synonym: Graph a = [Edge a]


Grappa

The type of a graph parser. It is parameterized over the type res of semantic values associated to graphs.

Type synonym: Grappa a b = Graph a -> (b,Graph a)


Exported operations:

getSemRep :: (a,[(b,[Int])]) -> a   

Access the semantic representation of the result of a graph parser.

Further infos:
  • solution complete, i.e., able to compute all solutions

pSucceed :: a -> [(b,[Int])] -> (a,[(b,[Int])])   

Given an arbitrary value v, pSucceed always succeeds returning v as a result without any consumption of the input graph g.

Further infos:
  • solution complete, i.e., able to compute all solutions

eoi :: [(a,[Int])] -> ((),[(a,[Int])])   

eoi succeeds only if the graph is already completely consumed. In this case, the result () is returned

Further infos:
  • partially defined
  • solution complete, i.e., able to compute all solutions

edge :: (a,[Int]) -> [(a,[Int])] -> ((),[(a,[Int])])   

The parser edge e succeeds only if the given edge e is part of the given input graph g.

(<|>) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (b,[(a,[Int])])) -> [(a,[Int])] -> (b,[(a,[Int])])   

The choice between two parsers.

(<*>) :: ([(a,[Int])] -> (b -> c,[(a,[Int])])) -> ([(a,[Int])] -> (b,[(a,[Int])])) -> [(a,[Int])] -> (c,[(a,[Int])])   

The successive application of two parsers where the result is constructed by function application.

(<$>) :: (a -> b) -> ([(c,[Int])] -> (a,[(c,[Int])])) -> [(c,[Int])] -> (b,[(c,[Int])])   

(<$) :: a -> ([(b,[Int])] -> (c,[(b,[Int])])) -> [(b,[Int])] -> (a,[(b,[Int])])   

(<*) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (c,[(a,[Int])])) -> [(a,[Int])] -> (b,[(a,[Int])])   

(*>) :: ([(a,[Int])] -> (b,[(a,[Int])])) -> ([(a,[Int])] -> (c,[(a,[Int])])) -> [(a,[Int])] -> (c,[(a,[Int])])   

chain :: ((Int,Int) -> [(a,[Int])] -> (b,[(a,[Int])])) -> (Int,Int) -> [(a,[Int])] -> ([b],[(a,[Int])])   

The combinator chain p (n1,n2) can be used to identify a non-empty chain of graphs that can be parsed with p. This chain has to be anchored between the nodes n1 and n2.