A simple graph implementation backed by
- data MGraph
- empty :: RDF rdf => rdf
- mkRdf :: RDF rdf => Triples -> Maybe BaseUrl -> PrefixMappings -> rdf
- triplesOf :: RDF rdf => rdf -> Triples
- select :: RDF rdf => rdf -> NodeSelector -> NodeSelector -> NodeSelector -> Triples
- query :: RDF rdf => rdf -> Maybe Node -> Maybe Node -> Maybe Node -> Triples
A map-based graph implementation.
Worst-case time complexity of the graph functions, with respect to the number of triples, are:
Return a RDF containing all the given triples. Handling of duplicates in the input depend on the particular RDF implementation.
Select the triples in the RDF that match the given selectors.
The three NodeSelector parameters are optional functions that match
the respective subject, predicate, and object of a triple. The triples
returned are those in the given graph for which the first selector
returns true when called on the subject, the second selector returns
true when called on the predicate, and the third selector returns true
when called on the ojbect. A
Nothing parameter is equivalent to a
function that always returns true for the appropriate node; but
implementations may be able to much more efficiently answer a select
that involves a
Nothing parameter rather than an
(id True) parameter.
The following call illustrates the use of select, and would result in the selection of all and only the triples that have a blank node as subject and a literal node as object:
select gr (Just isBNode) Nothing (Just isLNode)
Note: this function may be very slow; see the documentation for the particular RDF implementation for more information.
Return the triples in the RDF that match the given pattern, where the pattern (3 Maybe Node parameters) is interpreted as a triple pattern.
Maybe Node params are interpreted as the subject, predicate, and
object of a triple, respectively.
Just n is true iff the triple has
a node equal to
n in the appropriate location;
Nothing is always
true, regardless of the node in the appropriate location.
query rdf (Just n1) Nothing (Just n2) would return all
and only the triples that have
n1 as subject and
n2 as object,
regardless of the predicate of the triple.