ralphtq/elm-rdf/1.0.0

Rdf.SPARQL.Types

Types for building parameterised SPARQL queries against a quad store. The flagship type is GraphQueryBuilderSpec — a record describing what a query does, what kind of result it yields, and the GraphQueryFunction that constructs the actual SPARQL string given a graph + scope.

Query strings

type alias SPARQLquery =
String

A complete SPARQL query string (PREFIX declarations + body).

type alias SPARQLstring =
String

Any SPARQL fragment — e.g. a single statement or a result clause.

Query kinds

= MetadataQueryKind
| ResourcesOverviewQueryKind
| ResourceDetailsQueryKind
| SchemaOverviewQueryKind
| SchemaResourcesQueryKind
| InScopeTypesQueryKind
| InScopeSchemaResourcesQueryKind

Discriminator for the predefined query kinds in Rdf.SPARQL.QuadStoreQueries.*.

type alias GraphQueryKindKey =
String

String form of a GraphQueryKind for use as a dict key.

graphQueryKindToKey : GraphQueryKind -> GraphQueryKindKey

Project a GraphQueryKind to its string key.

Result constraints

String

A trailing SPARQL clause appended to a query — typically ORDER BY, LIMIT, or OFFSET.

Scope filters

= AllTypes

Type-scope discriminator. Currently only AllTypes is meaningful; the type exists so future revisions can add OnlyTypes (List IRI) etc. without breaking call sites.

= OutOfScopeFilter

Filter for scope-based query construction. OutOfScopeFilter excludes types known to be out-of-scope from results.

Builder spec + envelope

type alias GraphQueryFunction =
GraphId
-> Maybe TermId
-> Maybe PrefixDictionary
-> List SPARQLresultConstraint
-> SPARQLquery

The signature shared by every query-builder function.

  • GraphId — the focus graph the query runs against.
  • Maybe TermId — optional focus resource (for resource-scoped queries).
  • TypeScope — what range of types to consider.
  • Maybe PrefixDictionary — prefix bindings to emit; defaults to the canonical core prefixes when Nothing.
  • List SPARQLresultConstraint — trailing clauses (e.g. ORDER BY).

Returns the rendered SPARQLquery string.

{ name : String
, queryKind : GraphQueryKind
, description : String
, inScopeTypesFilter : Bool
, outOfScopeTypesFilter : Bool
, resultConstraints : List SPARQLresultConstraint
, queryFunction : GraphQueryFunction
, formattedSPARQL : Maybe String
}

A bundled description of a predefined query: its name, kind, description, default constraints, and the function that builds it.

inScopeTypesFilter and outOfScopeTypesFilter flag whether the caller should pre-resolve scope-related parameters before building.

formattedSPARQL is an optional cache of the pretty-printed query for display in editors / health checks — typically populated by a pass that runs the query through sparqljs.

type alias GraphQueryEnvelope =
( GraphQueryKind, SPARQLquery )

The pair of a query's kind discriminator and the rendered SPARQL string. Useful as the payload of an "execute this query" message.

Dict GraphQueryKindKey GraphQueryBuilderSpec

A registry of available query builders, keyed by GraphQueryKindKey.