Convert an Elm Quad into the JSON wire
shape produced and consumed by the TypeScript companion package
@ralphtq/elm-rdf-n3-quads.
Use this when your Elm code constructs quads that need to be sent
through a port to the TS side (e.g. for writeQuads,
shaclValidateWithQuads).
The three type aliases here (JSONrdfQuad, JSONrdfObject,
JSONrdfTermTypeAndValue) are structurally identical to the
record type aliases of the same name in
ralphtq/elm-rdf-n3-quads
(modules Rdf.Wire.Types / Rdf.Wire.Decode / Rdf.Wire.Encode).
Because Elm uses structural typing for record aliases, values
produced here can be passed wherever a Rdf.Wire.Types.JSONrdfQuad
is expected, without any conversion. They're defined here so this
package has no hard dependency on the wire package — useful while
both packages are pre-publish.
Wire shape for an RDF object term. Adds optional language and
datatype fields for literals.
Wire shape for a named-node, blank-node, or default-graph marker.
For the default graph the TS side sends { termType = "NamedNode", value = "", id = "" }.
Convert a list of Elm Quads to wire
JSONrdfQuads.
-- e.g. before sending to a port:
quads
|> Rdf.Core.Exporter.transformJSONquadsToN3Quads
|> sendQuadsToPortExposed so consumers can mix and match — e.g. send a single triple rather than a list.
Convert a QuadGraph to its wire shape.
The default graph becomes { termType = "NamedNode", value = "", id = "" }.
Convert a PredicateTerm to its
wire shape (always termType = "NamedNode").
Convert a non-literal RDF term (named node or blank node) to its
wire shape. Used for the subject position.
Convert an RDFterm to a wire
JSONrdfObject.
NonLiteral (NamedNode iri) → NamedNode objectNonLiteral (BlankNode bn) → BlankNode objectLiteral (LiteralString s (Just lang)) → Literal with language
and rdf:langString datatypeLiteral (LiteralString s Nothing) → Literal with rdf:langString datatypeLiteral (LiteralDataType s (Just (DataType iri))) → typed literalLiteral (LiteralDataType s Nothing) → "Unhandled" fallbackPredicate (PredicateNamedNode iri) → NamedNode (predicate-as-object)"Unexpected" fallbackThe "Unhandled" and "Unexpected" fallbacks are intentional escape
hatches to avoid silent data loss; the TS side ignores them in writers
and validators.
Wire shape for a complete RDF quad.