-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A SPARQL query generator and DSL, and a client to query a SPARQL server. -- -- hsparql includes a DSL to easily create queries, as well as methods to -- submit those queries to a SPARQL server, returning the results as -- simple Haskell data structures. Example queries are included in the -- tests: -- https://github.com/robstewart57/hsparql/blob/master/tests/DBPedia.hs. @package hsparql @version 0.2.2 -- | The query generator DSL for SPARQL, used when connecting to remote -- endpoints. module Database.HSparql.QueryGenerator -- | Execute a 'Select Query' action, returning the String -- representation of the query. createSelectQuery :: Query SelectQuery -> String -- | Execute a 'Construct Query' action, returning the String -- representation of the query. createConstructQuery :: Query ConstructQuery -> String -- | Execute a 'Ask Query' action, returning the String -- representation of the query. createAskQuery :: Query AskQuery -> String -- | Execute a 'Describe Query' action, returning the String -- representation of the query. createDescribeQuery :: Query DescribeQuery -> String -- | Add a prefix to the query, given an IRI reference, and return it. prefix :: String -> IRIRef -> Query Prefix -- | Create and return a variable to the query, usable in later -- expressions. var :: Query Variable -- | Restrict the query to only results for which values match constants in -- this triple, or for which the variables can be bound. triple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query Pattern constructTriple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query Pattern askTriple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query Pattern describeIRI :: IRIRef -> Query IRIRef -- | Add optional constraints on matches. Variable bindings within the -- optional action are lost, so variables must always be defined prior to -- opening the optional block. optional :: Query a -> Query Pattern -- | Add a union structure to the query pattern. As with optional -- blocks, variables must be defined prior to the opening of any block. union :: Query a -> Query b -> Query Pattern -- | Restrict results to only those for which the given expression is true. filterExpr :: TermLike a => a -> Query Pattern -- | Set duplicate handling to Distinct. By default, there are no -- reductions. distinct :: Query Duplicates -- | Set duplicate handling to Reduced. By default, there are no -- reductions. reduced :: Query Duplicates -- | Alias of orderNextAsc. orderNext :: TermLike a => a -> Query () -- | Order the results, after any previous ordering, based on the term, in -- ascending order. orderNextAsc :: TermLike a => a -> Query () -- | Order the results, after any previous ordering, based on the term, in -- descending order. orderNextDesc :: TermLike a => a -> Query () -- | Form a PrefixedName IRIRef, with the Prefix and -- reference name. (.:.) :: Prefix -> String -> IRIRef -- | Create an IRIRef with an absolute reference to the address at -- which it is located. iriRef :: String -> IRIRef -- | Add two terms. (.+.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Find the difference between two terms. (.-.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Multiply two terms. (.*.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Divide two terms. (./.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their equivalence. (.==.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their equivalence. (.!=.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their relative value. (.<.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their relative value. (.>.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their relative value. (.<=.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Create an expression which tests the relationship of the two operands, -- evaluating their relative value. (.>=.) :: (TermLike a, TermLike b) => a -> b -> Expr -- | Negate any term-like expression, for use, e.g., in filtering. notExpr :: TermLike a => a -> Expr str :: BuiltinFunc1 lang :: BuiltinFunc1 langMatches :: BuiltinFunc2 datatype :: BuiltinFunc1 bound :: Variable -> Expr sameTerm :: BuiltinFunc2 isIRI :: BuiltinFunc1 isURI :: BuiltinFunc1 isBlank :: BuiltinFunc1 isLiteral :: BuiltinFunc1 regex :: BuiltinFunc2 -- | Convert most query-related types to a String, most importantly -- QueryDatas. qshow :: QueryShow a => a -> String -- | The State monad applied to QueryData. type Query a = State QueryData a data Variable data Pattern data SelectQuery SelectQuery :: [Variable] -> SelectQuery queryVars :: SelectQuery -> [Variable] data ConstructQuery ConstructQuery :: [Pattern] -> ConstructQuery queryConstructs :: ConstructQuery -> [Pattern] data AskQuery AskQuery :: [Pattern] -> AskQuery queryAsk :: AskQuery -> [Pattern] data DescribeQuery DescribeQuery :: IRIRef -> DescribeQuery queryDescribe :: DescribeQuery -> IRIRef instance QueryShow QueryData instance QueryShow QueryForm instance QueryShow OrderBy instance QueryShow GroupGraphPattern instance QueryShow Pattern instance QueryShow Expr instance QueryShow Function instance QueryShow Relation instance QueryShow NumericExpr instance QueryShow Operation instance QueryShow VarOrTerm instance QueryShow GraphTerm instance QueryShow RDFLiteral instance QueryShow (Maybe IRIRef) instance QueryShow IRIRef instance QueryShow Variable instance QueryShow Prefix instance QueryShow Duplicates instance QueryShow a => QueryShow [a] instance TermLike Bool instance TermLike ([Char], IRIRef) instance TermLike ([Char], [Char]) instance TermLike [Char] instance TermLike Integer instance TermLike Expr instance TermLike IRIRef instance TermLike Variable module Database.HSparql.Connection -- | URI of the SPARQL endpoint. type EndPoint = String -- | Local representations of incoming XML results. data BindingValue -- | RDF Node (UNode, BNode, LNode) Bound :: Node -> BindingValue -- | Unbound result value Unbound :: BindingValue -- | Connect to remote EndPoint and find all possible bindings for -- the Variables in the SelectQuery action. selectQuery :: EndPoint -> Query SelectQuery -> IO (Maybe [[BindingValue]]) -- | Connect to remote EndPoint and construct TriplesGraph -- from given ConstructQuery action. Provisional -- implementation. constructQuery :: RDF rdf => EndPoint -> Query ConstructQuery -> IO rdf -- | Connect to remote EndPoint and find all possible bindings for -- the Variables in the SelectQuery action. askQuery :: EndPoint -> Query AskQuery -> IO Bool -- | Connect to remote EndPoint and construct TriplesGraph -- from given ConstructQuery action. Provisional -- implementation. describeQuery :: RDF rdf => EndPoint -> Query DescribeQuery -> IO rdf instance Show BindingValue instance Eq BindingValue