swish-0.3.0.3: A semantic web toolkit.

PortabilityDeriveFunctor, DeriveFoldable, DeriveTraversable, MultiParamTypeClasses
Stabilityexperimental
MaintainerDouglas Burke

Swish.RDF.GraphClass

Description

This module defines a Labelled Directed Graph and Label classes, and the Arc datatype.

Synopsis

Documentation

class (Eq (lg lb), Eq lb) => LDGraph lg lb whereSource

Labelled Directed Graph class

Minimum required implementation: setArcs, getArcs and containedIn.

NOTE: I wanted to declare this as a subclass of Functor, but the constraint on the label type seems to prevent that. So I've just declared specific instances to be Functors.

Methods

setArcs :: [Arc lb] -> lg lb -> lg lbSource

Replace the existing arcs in the graph.

getArcs :: lg lb -> [Arc lb]Source

Extract all the arcs from a graph

extract :: Selector lb -> lg lb -> lg lbSource

Extract those arcs that match the given Selector.

add :: lg lb -> lg lb -> lg lbSource

Add the two graphs

deleteSource

Arguments

:: lg lb

g1

-> lg lb

g2

-> lg lb

g2 - g1 -> g3

Remove those arcs in the first graph from the second graph

labels :: lg lb -> [lb]Source

Enumerate the distinct labels contained in a graph; that is, any label that appears in the subject, predicate or object position of an Arc.

nodes :: lg lb -> [lb]Source

Enumerate the distinct nodes contained in a graph; that is, any label that appears in the subject or object position of an Arc.

containedIn :: lg lb -> lg lb -> BoolSource

Test for graph containment in another.

update :: ([Arc lb] -> [Arc lb]) -> lg lb -> lg lbSource

Update the arcs in a graph using a supplied function.

Instances

Label lb => LDGraph NSGraph lb 
Label lb => LDGraph GraphMem lb 

replaceArcs :: LDGraph lg lb => lg lb -> [Arc lb] -> lg lbSource

Function to replace arcs in a graph with a given list of arcs

class (Eq lb, Show lb, Ord lb) => Label lb whereSource

Label class

A label may have a fixed binding, which means that the label identifies (is) a particular graph node, and different such labels are always distinct nodes. Alternatively, a label may be unbound (variable), which means that it is a placeholder for an unknown node label. Unbound node labels are used as graph-local identifiers for indicating when the same node appears in several arcs.

For the purposes of graph-isomorphism testing, fixed labels are matched when they are the same. Variable labels may be matched with any other variable label. Our definition of isomorphism (for RDF graphs) does not match variable labels with fixed labels.

Methods

labelIsVar :: lb -> BoolSource

Does this node have a variable binding?

labelHash :: Int -> lb -> IntSource

Calculate the hash of the label using the supplied seed.

getLocal :: lb -> StringSource

Extract the local id from a variable node.

makeLabel :: String -> lbSource

Make a label value from a local id.

data Arc lb Source

Arc type

Constructors

Arc 

Fields

asubj :: lb
 
apred :: lb
 
aobj :: lb
 

Instances

Functor Arc 
Foldable Arc 
Traversable Arc 
Eq lb => Eq (Arc lb) 
Ord lb => Ord (Arc lb) 
Show lb => Show (Arc lb) 

arcSubj :: Arc lb -> lbSource

arcPred :: Arc lb -> lbSource

arcObj :: Arc lb -> lbSource

arcSource

Arguments

:: lb

The subject of the arc.

-> lb

The predicate of the arc.

-> lb

The object of the arc.

-> Arc lb 

Create an arc.

arcToTriple :: Arc lb -> (lb, lb, lb)Source

arcFromTriple :: (lb, lb, lb) -> Arc lbSource

type Selector lb = Arc lb -> BoolSource

hasLabel :: Eq lb => lb -> Arc lb -> BoolSource

arcLabels :: Arc lb -> [lb]Source

Return all the labels in an arc.