hsparql-0.2.3: A SPARQL query generator and DSL, and a client to query a SPARQL server.

Safe HaskellNone

Database.HSparql.QueryGenerator

Contents

Description

The query generator DSL for SPARQL, used when connecting to remote endpoints.

Synopsis

Creating Queries

createSelectQuery :: Query SelectQuery -> StringSource

Execute a 'Select Query' action, returning the String representation of the query.

createConstructQuery :: Query ConstructQuery -> StringSource

Execute a 'Construct Query' action, returning the String representation of the query.

createAskQuery :: Query AskQuery -> StringSource

Execute a 'Ask Query' action, returning the String representation of the query.

createDescribeQuery :: Query DescribeQuery -> StringSource

Execute a 'Describe Query' action, returning the String representation of the query.

Query Actions

prefix :: Text -> IRIRef -> Query PrefixSource

Add a prefix to the query, given an IRI reference, and return it.

var :: Query VariableSource

Create and return a variable to the query, usable in later expressions.

triple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query PatternSource

Restrict the query to only results for which values match constants in this triple, or for which the variables can be bound.

constructTriple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query PatternSource

askTriple :: (TermLike a, TermLike b, TermLike c) => a -> b -> c -> Query PatternSource

describeIRI :: IRIRef -> Query IRIRefSource

optional :: Query a -> Query PatternSource

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.

union :: Query a -> Query b -> Query PatternSource

Add a union structure to the query pattern. As with optional blocks, variables must be defined prior to the opening of any block.

filterExpr :: TermLike a => a -> Query PatternSource

Restrict results to only those for which the given expression is true.

Duplicate handling

distinct :: Query DuplicatesSource

Set duplicate handling to Distinct. By default, there are no reductions.

reduced :: Query DuplicatesSource

Set duplicate handling to Reduced. By default, there are no reductions.

Order handling

orderNext :: TermLike a => a -> Query ()Source

Alias of orderNextAsc.

orderNextAsc :: TermLike a => a -> Query ()Source

Order the results, after any previous ordering, based on the term, in ascending order.

orderNextDesc :: TermLike a => a -> Query ()Source

Order the results, after any previous ordering, based on the term, in descending order.

Auxiliary

(.:.) :: Prefix -> Text -> IRIRefSource

Form a Node, with the Prefix and reference name.

iriRef :: Text -> IRIRefSource

Term Manipulation

Operations

(.+.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Add two terms.

(.-.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Find the difference between two terms.

(.*.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Multiply two terms.

(./.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Divide two terms.

Relations

(.==.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their equivalence.

(.!=.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their equivalence.

(.<.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their relative value.

(.>.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their relative value.

(.<=.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their relative value.

(.>=.) :: (TermLike a, TermLike b) => a -> b -> ExprSource

Create an expression which tests the relationship of the two operands, evaluating their relative value.

Negation

notExpr :: TermLike a => a -> ExprSource

Negate any term-like expression, for use, e.g., in filtering.

Builtin Functions

str :: BuiltinFunc1Source

lang :: BuiltinFunc1Source

langMatches :: BuiltinFunc2Source

datatype :: BuiltinFunc1Source

sameTerm :: BuiltinFunc2Source

isIRI :: BuiltinFunc1Source

isURI :: BuiltinFunc1Source

isBlank :: BuiltinFunc1Source

isLiteral :: BuiltinFunc1Source

regex :: BuiltinFunc2Source

Printing Queries

qshow :: QueryShow a => a -> StringSource

Convert most query-related types to a String, most importantly QueryDatas.

Types

type Query a = State QueryData aSource

The State monad applied to QueryData.

data Variable Source

Instances

QueryShow Variable 
TermLike Variable 

data Pattern Source

Instances

QueryShow Pattern 

data SelectQuery Source

Constructors

SelectQuery 

Fields

queryVars :: [Variable]
 

data AskQuery Source

Constructors

AskQuery 

Fields

queryAsk :: [Pattern]
 

data DescribeQuery Source

Constructors

DescribeQuery 

Fields

queryDescribe :: IRIRef