ralphtq/elm-rdf/1.0.0

Rdf.Core.QuadId

Quad-id manipulation. The wire format encodes a quad's coordinates as a colon-separated string subjectId:predicateId:objectId:graphId. These helpers construct and parse that form.

makeQuadId : Int -> Int -> Int -> QuadGraph -> QuadId

Construct a quad-id from three integer ids and a QuadGraph. Format: subjectId:predicateId:objectId:graphId. The graphId is "" for DefaultGraph and the IRI for QuadGraphNamedNode.

deconstructQuadId : QuadId -> ( Int, Int, Int )

Recover the (subjectId, predicateId, objectId) triple from a quad-id. Returns (0, 0, 0) for malformed input.

Splits on the first three colons only, so the graph component (which typically contains its own colons in IRIs/CURIEs) is correctly discarded rather than overflowing the parse.

escapeQuotes : String -> String

Stub for SPARQL-result literal escaping. Currently a no-op; present to mirror the JavaScript-side escapeQuotes slot.

termToId : RDFterm -> TermId

Render any RDFterm as its canonical string id.

  • NamedNode iri → iri
  • BlankNode bnId → "_:" ++ bnId
  • LiteralString s (Just lang) → "<s>@<lang>"
  • LiteralString s Nothing → "<s>"
  • LiteralDataType s (Just (DataType iri)) → "<s>^^<iri>"
  • LiteralDataType s Nothing → "<s>"
  • Predicate (PredicateNamedNode iri) → iri
  • Graph DefaultGraph → ""
  • Graph (QuadGraphNamedNode (IRIid iri)) → iri