robstewart57/hsparql — pull request #9 by haroldcarr (2014-08-16 15:08:24+00:00)
Title: Enable programmatic construction of triples.

Example usage:

callTest :: IO (Maybe [[BindingValue]])
callTest = test "http://localhost:3030/ds/query"
(False, UNode (T.pack "http://openhc.org/data/event/Slug_Magazine_Salt_Lake_City_Utah"))
(True , UNode (T.pack "http://xmlns.com/foaf/0.1/name"))
(True , LNode (PlainLL (T.pack "Slug Magazine") (T.pack "en")))

test :: String -> (Bool, Node) -> (Bool, Node) -> (Bool, Node) -> IO (Maybe [[BindingValue]])
test url (isSVar, sval) (isPVar, pval) (isOVar, oval) = selectQuery url q
where
q = do
svar <- var
pvar <- var
ovar <- var
triple (if isSVar then Var' svar else RDFNode sval)
(if isPVar then Var' pvar else RDFNode pval)
(if isOVar then Var' ovar else RDFNode oval)
return SelectQuery { queryVars = [svar, pvar, ovar] }

This works (with sparql endpoint being jena-fuseki-1.0.0).