AshR2RML.Type behaviour (AshR2RML v26.8.22)

Copy Markdown View Source

Semantic contract layered on top of Ash.Type.

AshR2RML.Type preserves the original datatype/lexical callbacks while generalizing the contract to RDF terms whose semantics are not XSD literals.

The public ontology remains authoritative. Implementing this behaviour only describes one executable Ash projection; it does not prove equivalence or grant persistence/actuation authority.

Summary

Types

rdf_term()

@type rdf_term() ::
  {:literal, String.t(), String.t()}
  | {:lang_literal, String.t(), String.t()}
  | {:iri, String.t()}
  | {:node, map()}

semantic_kind()

@type semantic_kind() :: :literal | :iri | :concept | :value_object | :resource

Callbacks

class_iri()

@callback class_iri() :: String.t() | nil

concept_scheme_iri()

@callback concept_scheme_iri() :: String.t() | nil

datatype_iri()

@callback datatype_iri() :: String.t() | nil

from_rdf(rdf_term)

(optional)
@callback from_rdf(rdf_term()) :: {:ok, term()} | {:error, term()}

from_rdf_lexical(t)

(optional)
@callback from_rdf_lexical(String.t()) :: {:ok, term()} | {:error, term()}

semantic_kind()

@callback semantic_kind() :: semantic_kind()

shacl_constraints()

@callback shacl_constraints() :: keyword() | map()

to_rdf(term)

@callback to_rdf(term()) :: rdf_term() | {:error, term()}

to_rdf_lexical(term)

@callback to_rdf_lexical(term()) :: String.t()

xsd_datatype()

@callback xsd_datatype() :: String.t() | nil

Functions

contract(module)

@spec contract(module()) :: {:ok, map()} | :error

decode(module, term)

@spec decode(module(), rdf_term()) :: {:ok, term()} | {:error, term()}

encode(module, value)

@spec encode(module(), term()) :: rdf_term() | {:error, term()}

semantic_type?(module)

@spec semantic_type?(term()) :: boolean()