ralphtq/elm-rdf/1.0.0

ralphtq/elm-rdf

General-purpose RDF primitives for Elm. Provides the data model (Quad, RDFterm, PredicateTerm, etc.), CURIE handling, common vocabulary IRIs (RDF, RDFS, OWL, XSD, SHACL, QUDT), prefix dictionaries, and quad-id helpers.

Pure-functional, no UI dependencies. Companion to ralphtq/elm-rdf-n3-quads (wire-format types + decoders for the TS bridge) and the @ralphtq/elm-rdf-n3-quads TypeScript package (in-browser N3.js + Comunica + SHACL validation behind a QuadStoreSession façade).

Status

Pre-release. 0.1.0 is the first cut — types + CURIEs + vocabulary + prefix utilities + quad-id helpers. Later releases will add a JSON exporter (v0.2.0) and SPARQL query builders (v0.3.0).

Install

elm install ralphtq/elm-rdf

Usage

import Rdf.Core.Types exposing (Quad, RDFterm(..), RDFnonLiteralTerm(..), PredicateTerm(..))
import Rdf.Core.Vocabulary.Rdf as Rdf
import Rdf.Core.Vocabulary.Rdfs as Rdfs
import Rdf.Core.CURIEs as CURIEs


-- Build a quad
exampleQuad : Quad
exampleQuad =
    { subject = NamedNode "http://example.org/Alice"
    , predicate = PredicateNamedNode Rdf.type_
    , object = NonLiteral (NamedNode "http://example.org/Person")
    , graph = QuadGraphNamedNode (IRIid "http://example.org/g")
    }


-- Shorten an IRI to a CURIE
exampleCurie : String
exampleCurie =
    CURIEs.convertToCURIE
        (Dict.fromList [ ( "rdfs", Rdfs.namespace ) ])
        Rdfs.label
-- "rdfs:label"

Exposed modules

  • Rdf.Core.Types — IRI, Prefix, Quad, RDFterm, RDFnonLiteralTerm, RDFliteralTerm, PredicateTerm, QuadGraph, NamedNodeId, BlankNodeId, KnownTriple, DataType, QuadId, …
  • Rdf.Core.CURIEs — convertToCURIE, extractBaseUri, extractLocalName
  • Rdf.Core.QuadId — makeQuadId, deconstructQuadId, escapeQuotes, termToId
  • Rdf.Core.Prefixes — corePrefixDict, coreInversePrefixDict, makeSPARQLprefixes, findDuplicates, plus the QUDT prefix list
  • Rdf.Core.Vocabulary.{Rdf,Rdfs,Owl,Xsd,Shacl,Qudt} — canonical IRIs for each namespace, plus a namespace : IRI constant per module

Companion packages

PackageWhat
ralphtq/elm-rdf-n3-quadsJSON wire types + decoders mirroring the TS bridge. Adds Rdf.Wire.* modules.
@ralphtq/elm-rdf-n3-quads (npm)TS in-browser quad store via N3.js + Comunica.
@ralphtq/rdf-n3-quads-elm-ports (npm)Thin Elm-ports adapter.

License

MIT. See LICENSE.