/usr/share/doc/libghc-swish-doc/html/Swish-RDF-Query.html is in libghc-swish-doc 0.9.1.10-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Swish.RDF.Query</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="file:///usr/share/javascript/mathjax/MathJax.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Swish-RDF-Query.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/Swish-RDF-Query.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">swish-0.9.1.10: A semantic web toolkit.</p></div><div id="content"><div id="module-header"><table class="info"><tr><th valign="top">Copyright</th><td>(c) 2003 Graham Klyne 2009 Vasili I Galchin 2011 2012 2014 Douglas Burke</td></tr><tr><th>License</th><td>GPL V2</td></tr><tr><th>Maintainer</th><td>Douglas Burke</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Portability</th><td>CPP</td></tr><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell98</td></tr></table><p class="caption">Swish.RDF.Query</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">Utility routines</a></li><li><a href="#g:2">Exported for testing</a></li></ul></div><div id="description"><p class="caption">Description</p><div class="doc"><p>This module defines functions for querying an RDF graph to obtain
a set of variable substitutions, and to apply a set of variable
substitutions to a query pattern to obtain a new graph.</p><p>It also defines a few primitive graph access functions.</p><p>A minimal example is shown below, where we query a very simple
graph:</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>:set -XOverloadedStrings
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Swish.RDF
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Swish.RDF.Parser.N3 (parseN3fromText)
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Swish.RDF.Query
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Swish.VarBinding (VarBinding(vbMap))
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Network.URI (parseURI)
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Data.Maybe (fromJust, mapMaybe)
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>let qparse = either error id . parseN3fromText
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>let igr = qparse "@prefix a: <http://example.com/>. a:a a a:A ; a:foo a:bar. a:b a a:B ; a:foo a:bar."
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>let qgr = qparse "?node a ?type."
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>let ans = rdfQueryFind qgr igr
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>:t ans
</code></strong>ans :: [Swish.RDF.VarBinding.RDFVarBinding]
<code class="prompt">>>> </code><strong class="userinput"><code>ans
</code></strong>[[(?node,a:a),(?type,a:A)],[(?node,a:b),(?type,a:B)]]
<code class="prompt">>>> </code><strong class="userinput"><code>let bn = toRDFLabel . fromJust . parseURI $ "http://example.com/B"
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>let arcs = rdfFindArcs (rdfObjEq bn) igr
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>:t arcs
</code></strong>arcs :: [RDFTriple]
<code class="prompt">>>> </code><strong class="userinput"><code>arcs
</code></strong>[(a:b,rdf:type,a:B)]
<code class="prompt">>>> </code><strong class="userinput"><code>let lbls = mapMaybe (`vbMap` (Var "type")) ans
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>:t lbls
</code></strong>lbls :: [RDFLabel]
<code class="prompt">>>> </code><strong class="userinput"><code>lbls
</code></strong>[a:A,a:B]
</pre></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:rdfQueryFind">rdfQueryFind</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]</li><li class="src short"><a href="#v:rdfQueryFilter">rdfQueryFilter</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBindingFilter">RDFVarBindingFilter</a> -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]</li><li class="src short"><a href="#v:rdfQueryBack">rdfQueryBack</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]]</li><li class="src short"><a href="#v:rdfQueryBackFilter">rdfQueryBackFilter</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBindingFilter">RDFVarBindingFilter</a> -> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]]</li><li class="src short"><a href="#v:rdfQueryBackModify">rdfQueryBackModify</a> :: <a href="Swish-VarBinding.html#t:VarBindingModify">VarBindingModify</a> a b -> [[<a href="Swish-VarBinding.html#t:VarBinding">VarBinding</a> a b]] -> [[<a href="Swish-VarBinding.html#t:VarBinding">VarBinding</a> a b]]</li><li class="src short"><a href="#v:rdfQueryInstance">rdfQueryInstance</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]</li><li class="src short"><a href="#v:rdfQuerySubs">rdfQuerySubs</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>]</li><li class="src short"><a href="#v:rdfQueryBackSubs">rdfQueryBackSubs</a> :: [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [[(<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>])]]</li><li class="src short"><a href="#v:rdfQuerySubsAll">rdfQuerySubsAll</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [(<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>])]</li><li class="src short"><a href="#v:rdfQuerySubsBlank">rdfQuerySubsBlank</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>]</li><li class="src short"><a href="#v:rdfQueryBackSubsBlank">rdfQueryBackSubsBlank</a> :: [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [[<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>]]</li><li class="src short"><a href="#v:rdfFindArcs">rdfFindArcs</a> :: (<a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a>]</li><li class="src short"><a href="#v:rdfSubjEq">rdfSubjEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:rdfPredEq">rdfPredEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:rdfObjEq">rdfObjEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:rdfFindPredVal">rdfFindPredVal</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]</li><li class="src short"><a href="#v:rdfFindPredInt">rdfFindPredInt</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Prelude.html#t:Integer">Integer</a>]</li><li class="src short"><a href="#v:rdfFindValSubj">rdfFindValSubj</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]</li><li class="src short"><a href="#v:rdfFindList">rdfFindList</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]</li><li class="src short"><a href="#v:allp">allp</a> :: [a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>] -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:anyp">anyp</a> :: [a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>] -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a></li><li class="src short"><a href="#v:rdfQuerySubs2">rdfQuerySubs2</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> (<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>])</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:rdfQueryFind" class="def">rdfQueryFind</a> <a href="src/Swish-RDF-Query.html#rdfQueryFind" class="link">Source</a> <a href="#v:rdfQueryFind" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc"><p>The query graph.</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc"><p>The target graph.</p></td></tr><tr><td class="src">-> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]</td><td class="doc"><p>Each element represents a set of variable bindings that make the query graph a
subgraph of the target graph. The list can be empty.</p></td></tr></table></div><div class="doc"><p>Basic graph-query function.</p><p>The triples of the query graph are matched sequentially
against the target graph, each taking account of any
variable bindings that have already been determined,
and adding new variable bindings as triples containing
query variables are matched against the graph.</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryFilter" class="def">rdfQueryFilter</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBindingFilter">RDFVarBindingFilter</a> -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] <a href="src/Swish-RDF-Query.html#rdfQueryFilter" class="link">Source</a> <a href="#v:rdfQueryFilter" class="selflink">#</a></p><div class="doc"><p>RDF query filter.</p><p>This function applies a supplied query binding
filter to the result from a call of <code><a href="Swish-RDF-Query.html#v:rdfQueryFind">rdfQueryFind</a></code>.</p><p>If none of the query bindings found satisfy the filter, a null
list is returned (which is what <code><a href="Swish-RDF-Query.html#v:rdfQueryFind">rdfQueryFind</a></code> returns if the
query cannot be satisfied).</p><p>(Because of lazy evaluation, this should be as efficient as
applying the filter as the search proceeds. I started to build
the filter logic into the query function itself, with consequent
increase in complexity, until I remembered lazy evaluation lets
me keep things separate.)</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryBack" class="def">rdfQueryBack</a> <a href="src/Swish-RDF-Query.html#rdfQueryBack" class="link">Source</a> <a href="#v:rdfQueryBack" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc"><p>Query graph</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc"><p>Target graph</p></td></tr><tr><td class="src">-> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Reverse graph-query function.</p><p>Similar to <code><a href="Swish-RDF-Query.html#v:rdfQueryFind">rdfQueryFind</a></code>, but with different success criteria.
The query graph is matched against the supplied graph,
but not every triple of the query is required to be matched.
Rather, every triple of the target graph must be matched,
and substitutions for just the variables thus bound are
returned. In effect, these are subsitutions in the query
that entail the target graph (where <code>rdfQueryFind</code> returns
substitutions that are entailed by the target graph).</p><p>Multiple substitutions may be used together, so the result
returned is a list of lists of query bindings. Each inner
list contains several variable bindings that must all be applied
separately to the closure antecendents to obtain a collection of
expressions that together are antecedent to the supplied
conclusion. A null list of bindings returned means the
conclusion can be inferred without any antecedents.</p><p>Note: in back-chaining, the conditions required to prove each
target triple are derived independently, using the inference rule
for each such triple, so there are no requirements to check
consistency with previously determined variable bindings, as
there are when doing forward chaining. A result of this is that
there may be redundant triples generated by the back-chaining
process. Any process using back-chaining should deal with the
results returned accordingly.</p><p>An empty outer list is returned if no combination of
substitutions can infer the supplied target.</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryBackFilter" class="def">rdfQueryBackFilter</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBindingFilter">RDFVarBindingFilter</a> -> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] <a href="src/Swish-RDF-Query.html#rdfQueryBackFilter" class="link">Source</a> <a href="#v:rdfQueryBackFilter" class="selflink">#</a></p><div class="doc"><p>RDF back-chaining query filter. This function applies a supplied
query binding filter to the result from a call of <code><a href="Swish-RDF-Query.html#v:rdfQueryBack">rdfQueryBack</a></code>.</p><p>Each inner list contains bindings that must all be used to satisfy
the backchain query, so if any query binding does not satisfy the
filter, the entire corresponding row is removed</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryBackModify" class="def">rdfQueryBackModify</a> :: <a href="Swish-VarBinding.html#t:VarBindingModify">VarBindingModify</a> a b -> [[<a href="Swish-VarBinding.html#t:VarBinding">VarBinding</a> a b]] -> [[<a href="Swish-VarBinding.html#t:VarBinding">VarBinding</a> a b]] <a href="src/Swish-RDF-Query.html#rdfQueryBackModify" class="link">Source</a> <a href="#v:rdfQueryBackModify" class="selflink">#</a></p><div class="doc"><p>RDF back-chaining query modifier. This function applies a supplied
query binding modifier to the result from a call of <code><a href="Swish-RDF-Query.html#v:rdfQueryBack">rdfQueryBack</a></code>.</p><p>Each inner list contains bindings that must all be used to satisfy
a backchaining query, so if any query binding does not satisfy the
filter, the entire corresponding row is removed</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryInstance" class="def">rdfQueryInstance</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] <a href="src/Swish-RDF-Query.html#rdfQueryInstance" class="link">Source</a> <a href="#v:rdfQueryInstance" class="selflink">#</a></p><div class="doc"><p>Simple entailment (instance) graph query.</p><p>This function queries a graph to find instances of the
query graph in the target graph. It is very similar
to the normal forward chaining query <code><a href="Swish-RDF-Query.html#v:rdfQueryFind">rdfQueryFind</a></code>,
except that blank nodes rather than query variable nodes
in the query graph are matched against nodes in the target
graph. Neither graph should contain query variables.</p><p>An instance is defined by the RDF semantics specification,
per <a href="http://www.w3.org/TR/rdf-mt/">http://www.w3.org/TR/rdf-mt/</a>, and is obtained by replacing
blank nodes with URIs, literals or other blank nodes. RDF
simple entailment can be determined in terms of instances.
This function looks for a subgraph of the target graph that
is an instance of the query graph, which is a necessary and
sufficient condition for RDF entailment (see the Interpolation
Lemma in RDF Semantics, section 1.2).</p><p>It is anticipated that this query function can be used in
conjunction with backward chaining to determine when the
search for sufficient antecendents to determine some goal
has been concluded.</p></div></div><div class="top"><p class="src"><a id="v:rdfQuerySubs" class="def">rdfQuerySubs</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>] <a href="src/Swish-RDF-Query.html#rdfQuerySubs" class="link">Source</a> <a href="#v:rdfQuerySubs" class="selflink">#</a></p><div class="doc"><p>Graph substitution function.</p><p>Uses the supplied variable bindings to substitute variables in
a supplied graph, returning a list of result graphs corresponding
to each set of variable bindings applied to the input graph.
This function is used for formward chaining substitutions, and
returns only those result graphs for which all query variables
are bound.</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryBackSubs" class="def">rdfQueryBackSubs</a> :: [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [[(<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>])]] <a href="src/Swish-RDF-Query.html#rdfQueryBackSubs" class="link">Source</a> <a href="#v:rdfQueryBackSubs" class="selflink">#</a></p><div class="doc"><p>Graph back-substitution function.</p><p>Uses the supplied variable bindings from <code><a href="Swish-RDF-Query.html#v:rdfQueryBack">rdfQueryBack</a></code> to perform
a series of variable substitutions in a supplied graph, returning
a list of lists of result graphs corresponding to each set of variable
bindings applied to the input graphs.</p><p>The outer list of the result contains alternative antecedent lists
that satisfy the query goal. Each inner list contains graphs that
must all be inferred to satisfy the query goal.</p></div></div><div class="top"><p class="src"><a id="v:rdfQuerySubsAll" class="def">rdfQuerySubsAll</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [(<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>])] <a href="src/Swish-RDF-Query.html#rdfQuerySubsAll" class="link">Source</a> <a href="#v:rdfQuerySubsAll" class="selflink">#</a></p><div class="doc"><p>Graph substitution function.</p><p>This function performs the substitutions and returns a list of
result graphs each paired with a list unbound variables in each.</p></div></div><div class="top"><p class="src"><a id="v:rdfQuerySubsBlank" class="def">rdfQuerySubsBlank</a> :: [<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>] <a href="src/Swish-RDF-Query.html#rdfQuerySubsBlank" class="link">Source</a> <a href="#v:rdfQuerySubsBlank" class="selflink">#</a></p><div class="doc"><p>Graph substitution function.</p><p>This function performs each of the substitutions in <code>vars</code>, and
replaces any nodes corresponding to unbound query variables
with new blank nodes.</p></div></div><div class="top"><p class="src"><a id="v:rdfQueryBackSubsBlank" class="def">rdfQueryBackSubsBlank</a> :: [[<a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a>]] -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [[<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>]] <a href="src/Swish-RDF-Query.html#rdfQueryBackSubsBlank" class="link">Source</a> <a href="#v:rdfQueryBackSubsBlank" class="selflink">#</a></p><div class="doc"><p>Graph back-substitution function, replacing variables with bnodes.</p><p>Uses the supplied variable bindings from <code><a href="Swish-RDF-Query.html#v:rdfQueryBack">rdfQueryBack</a></code> to perform
a series of variable substitutions in a supplied graph, returning
a list of lists of result graphs corresponding to each set of variable
bindings applied to the input graphs.</p><p>The outer list of the result contains alternative antecedent lists
that satisfy the query goal. Each inner list contains graphs that
must all be inferred to satisfy the query goal.</p></div></div><div class="top"><p class="src"><a id="v:rdfFindArcs" class="def">rdfFindArcs</a> :: (<a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>) -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> [<a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a>] <a href="src/Swish-RDF-Query.html#rdfFindArcs" class="link">Source</a> <a href="#v:rdfFindArcs" class="selflink">#</a></p><div class="doc"><p>Take a predicate on an
RDF statement and a graph, and returns all statements in the graph
satisfying that predicate.</p><p>Use combinations of these as follows:</p><ul><li>find all statements with given subject:
<code>rdfFindArcs (rdfSubjEq s)</code></li><li>find all statements with given property:
<code>rdfFindArcs (rdfPredEq p)</code></li><li>find all statements with given object:
<code>rdfFindArcs (rdfObjEq o)</code></li><li>find all statements matching conjunction of these conditions:
<code>rdfFindArcs (<code><a href="Swish-RDF-Query.html#v:allp">allp</a></code> [...])</code></li><li>find all statements matching disjunction of these conditions:
<code>rdfFindArcs (<code><a href="Swish-RDF-Query.html#v:anyp">anyp</a></code> [...])</code></li></ul><p>Custom predicates can also be used.</p></div></div><div class="top"><p class="src"><a id="v:rdfSubjEq" class="def">rdfSubjEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Swish-RDF-Query.html#rdfSubjEq" class="link">Source</a> <a href="#v:rdfSubjEq" class="selflink">#</a></p><div class="doc"><p>Test if statement has given subject</p></div></div><div class="top"><p class="src"><a id="v:rdfPredEq" class="def">rdfPredEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Swish-RDF-Query.html#rdfPredEq" class="link">Source</a> <a href="#v:rdfPredEq" class="selflink">#</a></p><div class="doc"><p>Test if statement has given predicate</p></div></div><div class="top"><p class="src"><a id="v:rdfObjEq" class="def">rdfObjEq</a> :: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> <a href="Swish-RDF-Graph.html#t:RDFTriple">RDFTriple</a> -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Swish-RDF-Query.html#rdfObjEq" class="link">Source</a> <a href="#v:rdfObjEq" class="selflink">#</a></p><div class="doc"><p>Test if statement has given object</p></div></div><div class="top"><p class="src"><a id="v:rdfFindPredVal" class="def">rdfFindPredVal</a> <a href="src/Swish-RDF-Query.html#rdfFindPredVal" class="link">Source</a> <a href="#v:rdfFindPredVal" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>subject</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>predicate</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Find values of given predicate for a given subject</p></div></div><div class="top"><p class="src"><a id="v:rdfFindPredInt" class="def">rdfFindPredInt</a> <a href="src/Swish-RDF-Query.html#rdfFindPredInt" class="link">Source</a> <a href="#v:rdfFindPredInt" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>subject</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>predicate</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> [<a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Prelude.html#t:Integer">Integer</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Find integer values of a given predicate for a given subject</p></div></div><div class="top"><p class="src"><a id="v:rdfFindValSubj" class="def">rdfFindValSubj</a> <a href="src/Swish-RDF-Query.html#rdfFindValSubj" class="link">Source</a> <a href="#v:rdfFindValSubj" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>predicate</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a></td><td class="doc"><p>object</p></td></tr><tr><td class="src">-> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a></td><td class="doc empty"> </td></tr><tr><td class="src">-> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]</td><td class="doc empty"> </td></tr></table></div><div class="doc"><p>Find all subjects that match (subject, predicate, object) in the graph.</p></div></div><div class="top"><p class="src"><a id="v:rdfFindList" class="def">rdfFindList</a> :: <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> <a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a> -> [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>] <a href="src/Swish-RDF-Query.html#rdfFindList" class="link">Source</a> <a href="#v:rdfFindList" class="selflink">#</a></p><div class="doc"><p>Return a list of nodes that comprise an rdf:collection value,
given the head element of the collection. If the list is
ill-formed then an arbitrary value is returned.</p></div></div><h1 id="g:1">Utility routines</h1><div class="top"><p class="src"><a id="v:allp" class="def">allp</a> :: [a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>] -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Swish-RDF-Query.html#allp" class="link">Source</a> <a href="#v:allp" class="selflink">#</a></p><div class="doc"><p>Test if a value satisfies all predicates in a list</p></div></div><div class="top"><p class="src"><a id="v:anyp" class="def">anyp</a> :: [a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a>] -> a -> <a href="file:///usr/share/doc/ghc-doc/html/libraries/base-4.9.1.0/Data-Bool.html#t:Bool">Bool</a> <a href="src/Swish-RDF-Query.html#anyp" class="link">Source</a> <a href="#v:anyp" class="selflink">#</a></p><div class="doc"><p>Test if a value satisfies any predicate in a list</p></div></div><h1 id="g:2">Exported for testing</h1><div class="top"><p class="src"><a id="v:rdfQuerySubs2" class="def">rdfQuerySubs2</a> :: <a href="Swish-RDF-VarBinding.html#t:RDFVarBinding">RDFVarBinding</a> -> <a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a> -> (<a href="Swish-RDF-Graph.html#t:RDFGraph">RDFGraph</a>, [<a href="Swish-RDF-Graph.html#t:RDFLabel">RDFLabel</a>]) <a href="src/Swish-RDF-Query.html#rdfQuerySubs2" class="link">Source</a> <a href="#v:rdfQuerySubs2" class="selflink">#</a></p><div class="doc"><p>This function applies a substitution for a single set of variable
bindings, returning the result and a list of unbound variables.
It uses a state transformer monad to collect the list of
unbound variables.</p><p>Adding an empty graph forces elimination of duplicate arcs.</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.3</p></div></body></html>
|