diff --git a/CHANGELOG.md b/CHANGELOG.md index 203c5a2..e568d83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,17 @@ This project adheres to [Semantic Versioning](http://semver.org/) and - `:implicit_base` option on the `RDF.Turtle.Encoder` - `:base_description` option on the `RDF.Turtle.Encoder` - `RDF.Resource.t` type -- `RDF.Triple.coercible_t`, `RDF.Quad.coercible_t`, `RDF.Star.Triple.coercible_t` - and `RDF.Star.Quad.coercible_t` types +- `RDF.Triple.coercible`, `RDF.Quad.coercible`, `RDF.Star.Triple.coercible` + and `RDF.Star.Quad.coercible` types + +### Changed + +- some types were renamed for consistency reasons; the old types were deprecated + and will be removed in v0.11 + - `RDF.Statement.coercible_t` -> `RDF.Statement.coercible` + - `RDF.Star.Statement.coercible_t` -> `RDF.Star.Statement.coercible` + - `RDF.Triple.t_values` -> `RDF.Triple.mapping_value` + - `RDF.Quad.t_values` -> `RDF.Quad.mapping_value` ### Fixed diff --git a/lib/rdf/blank_node.ex b/lib/rdf/blank_node.ex index 8b87f20..dfccbfc 100644 --- a/lib/rdf/blank_node.ex +++ b/lib/rdf/blank_node.ex @@ -10,9 +10,7 @@ defmodule RDF.BlankNode do and """ - @type t :: %__MODULE__{ - value: String.t() - } + @type t :: %__MODULE__{value: String.t()} @enforce_keys [:value] defstruct [:value] diff --git a/lib/rdf/description.ex b/lib/rdf/description.ex index e80b7b7..724ead8 100644 --- a/lib/rdf/description.ex +++ b/lib/rdf/description.ex @@ -26,7 +26,7 @@ defmodule RDF.Description do @type predications :: %{Statement.predicate() => %{Statement.object() => nil}} @type input :: - Statement.coercible_t() + Statement.coercible() | { Statement.coercible_predicate(), Statement.coercible_object() | [Statement.coercible_object()] @@ -36,7 +36,7 @@ defmodule RDF.Description do Statement.coercible_object() | [Statement.coercible_object()] } | [ - Statement.coercible_t() + Statement.coercible() | { Statement.coercible_predicate(), Statement.coercible_object() | [Statement.coercible_object()] diff --git a/lib/rdf/graph.ex b/lib/rdf/graph.ex index c880d98..3885d5b 100644 --- a/lib/rdf/graph.ex +++ b/lib/rdf/graph.ex @@ -30,7 +30,7 @@ defmodule RDF.Graph do } @type input :: - Statement.coercible_t() + Statement.coercible() | { Statement.coercible_subject(), Description.input() diff --git a/lib/rdf/iri.ex b/lib/rdf/iri.ex index de6f62a..05e11a3 100644 --- a/lib/rdf/iri.ex +++ b/lib/rdf/iri.ex @@ -19,9 +19,7 @@ defmodule RDF.IRI do alias RDF.Namespace import RDF.Guards - @type t :: %__MODULE__{ - value: String.t() - } + @type t :: %__MODULE__{value: String.t()} @type coercible :: String.t() | URI.t() | module | t diff --git a/lib/rdf/quad.ex b/lib/rdf/quad.ex index 793a49f..be171f7 100644 --- a/lib/rdf/quad.ex +++ b/lib/rdf/quad.ex @@ -15,7 +15,7 @@ defmodule RDF.Quad do Statement.graph_name() } - @type coercible_t :: + @type coercible :: { Statement.coercible_subject(), Statement.coercible_predicate(), @@ -23,7 +23,9 @@ defmodule RDF.Quad do Statement.coercible_graph_name() } - @type t_values :: {String.t(), String.t(), any, String.t()} + @type mapping_value :: {String.t(), String.t(), any, String.t()} + # deprecated: This will be removed in v0.11. + @type t_values :: mapping_value @doc """ Creates a `RDF.Quad` with proper RDF values. @@ -91,7 +93,7 @@ defmodule RDF.Quad do iex> RDF.Quad.new {EX.S, :p, 42, EX.Graph}, RDF.PropertyMap.new(p: EX.p) {RDF.iri("http://example.com/S"), RDF.iri("http://example.com/p"), RDF.literal(42), RDF.iri("http://example.com/Graph")} """ - @spec new(Statement.coercible_t(), PropertyMap.t() | nil) :: t + @spec new(Statement.coercible(), PropertyMap.t() | nil) :: t def new(statement, property_map \\ nil) def new({subject, predicate, object, graph_name}, property_map) do @@ -120,7 +122,7 @@ defmodule RDF.Quad do {"http://example.com/S", :p, 42, "http://example.com/Graph"} """ - @spec values(t, keyword) :: t_values | nil + @spec values(t, keyword) :: mapping_value | nil def values(quad, opts \\ []) do if property_map = PropertyMap.from_opts(opts) do map(quad, Statement.default_property_mapping(property_map)) @@ -154,7 +156,7 @@ defmodule RDF.Quad do {:S, :p, 42, ~I} """ - @spec map(t, Statement.term_mapping()) :: t_values | nil + @spec map(t, Statement.term_mapping()) :: mapping_value | nil def map({subject, predicate, object, graph_name}, fun) do with subject_value when not is_nil(subject_value) <- fun.({:subject, subject}), predicate_value when not is_nil(predicate_value) <- fun.({:predicate, predicate}), diff --git a/lib/rdf/resource.ex b/lib/rdf/resource.ex index 93794dd..17113c8 100644 --- a/lib/rdf/resource.ex +++ b/lib/rdf/resource.ex @@ -6,4 +6,6 @@ defmodule RDF.Resource do alias RDF.{IRI, BlankNode} @type t :: IRI.t() | BlankNode.t() + + @type coercible :: IRI.coercible() | BlankNode.t() end diff --git a/lib/rdf/star/quad.ex b/lib/rdf/star/quad.ex index d6fbd50..38bbfa7 100644 --- a/lib/rdf/star/quad.ex +++ b/lib/rdf/star/quad.ex @@ -17,7 +17,7 @@ defmodule RDF.Star.Quad do Statement.graph_name() } - @type coercible_t :: + @type coercible :: { Statement.coercible_subject(), Statement.coercible_predicate(), @@ -25,8 +25,6 @@ defmodule RDF.Star.Quad do Statement.coercible_graph_name() } - @type t_values :: {String.t(), String.t(), any, String.t()} - @doc """ Creates a `RDF.Star.Quad` with proper RDF-star values. @@ -104,7 +102,7 @@ defmodule RDF.Star.Quad do {{~I, ~I, RDF.literal(42)}, ~I, RDF.literal(43), ~I} """ - @spec new(Statement.coercible_t(), PropertyMap.t() | nil) :: t + @spec new(Statement.coercible(), PropertyMap.t() | nil) :: t def new(statement, property_map \\ nil) def new({subject, predicate, object, graph_name}, property_map) do diff --git a/lib/rdf/star/statement.ex b/lib/rdf/star/statement.ex index 31bc077..4c99ea3 100644 --- a/lib/rdf/star/statement.ex +++ b/lib/rdf/star/statement.ex @@ -19,7 +19,9 @@ defmodule RDF.Star.Statement do @type coercible_graph_name :: RDF.Statement.coercible_graph_name() @type t :: Triple.t() | Quad.t() - @type coercible_t :: Triple.coercible_t() | Quad.coercible_t() + @type coercible :: Triple.coercible() | Quad.coercible() + # deprecated: This will be removed in v0.11. + @type coercible_t :: coercible @type term_mapping :: RDF.Statement.term_mapping() @@ -60,7 +62,7 @@ defmodule RDF.Star.Statement do iex> RDF.Star.Statement.coerce {"http://example.com/S", "http://example.com/p", 42, "http://example.com/Graph"} {~I, ~I, RDF.literal(42), ~I} """ - @spec coerce(coercible_t(), PropertyMap.t() | nil) :: Triple.t() | Quad.t() + @spec coerce(coercible(), PropertyMap.t() | nil) :: Triple.t() | Quad.t() def coerce(statement, property_map \\ nil) def coerce({_, _, _} = triple, property_map), do: Triple.new(triple, property_map) def coerce({_, _, _, _} = quad, property_map), do: Quad.new(quad, property_map) diff --git a/lib/rdf/star/triple.ex b/lib/rdf/star/triple.ex index 4287595..7dfdd05 100644 --- a/lib/rdf/star/triple.ex +++ b/lib/rdf/star/triple.ex @@ -12,7 +12,7 @@ defmodule RDF.Star.Triple do @type t :: {Statement.subject(), Statement.predicate(), Statement.object()} - @type coercible_t :: + @type coercible :: { Statement.coercible_subject(), Statement.coercible_predicate(), @@ -88,7 +88,7 @@ defmodule RDF.Star.Triple do iex> RDF.Star.Triple.new({{EX.S, :p, 42}, :p2, 43}, RDF.PropertyMap.new(p: EX.p, p2: EX.p2)) {{~I, ~I, RDF.literal(42)}, ~I, RDF.literal(43)} """ - @spec new(Statement.coercible_t(), PropertyMap.t() | nil) :: t + @spec new(Statement.coercible(), PropertyMap.t() | nil) :: t def new(statement, property_map \\ nil) def new({subject, predicate, object}, property_map), diff --git a/lib/rdf/statement.ex b/lib/rdf/statement.ex index f9636cd..d03e86e 100644 --- a/lib/rdf/statement.ex +++ b/lib/rdf/statement.ex @@ -13,8 +13,8 @@ defmodule RDF.Statement do @type object :: Resource.t() | Literal.t() @type graph_name :: Resource.t() | nil - @type coercible_subject :: subject | atom | String.t() - @type coercible_predicate :: predicate | atom | String.t() + @type coercible_subject :: Resource.coercible() + @type coercible_predicate :: Resource.coercible() @type coercible_object :: object | any @type coercible_graph_name :: graph_name | atom | String.t() @@ -23,7 +23,9 @@ defmodule RDF.Statement do @type term_mapping :: (qualified_term -> any | nil) @type t :: Triple.t() | Quad.t() - @type coercible_t :: Triple.coercible_t() | Quad.coercible_t() + @type coercible :: Triple.coercible() | Quad.coercible() + # deprecated: This will be removed in v0.11. + @type coercible_t :: coercible @doc """ Creates a `RDF.Triple` or `RDF.Quad` with proper RDF values. @@ -62,7 +64,7 @@ defmodule RDF.Statement do iex> RDF.Statement.coerce {"http://example.com/S", "http://example.com/p", 42, "http://example.com/Graph"} {~I, ~I, RDF.literal(42), ~I} """ - @spec coerce(coercible_t(), PropertyMap.t() | nil) :: Triple.t() | Quad.t() + @spec coerce(coercible(), PropertyMap.t() | nil) :: Triple.t() | Quad.t() def coerce(statement, property_map \\ nil) def coerce({_, _, _} = triple, property_map), do: Triple.new(triple, property_map) def coerce({_, _, _, _} = quad, property_map), do: Quad.new(quad, property_map) @@ -140,7 +142,7 @@ defmodule RDF.Statement do {"http://example.com/S", :p, 42} """ - @spec values(t, keyword) :: Triple.t_values() | Quad.t_values() | nil + @spec values(t, keyword) :: Triple.mapping_value() | Quad.mapping_value() | nil def values(quad, opts \\ []) def values({_, _, _} = triple, opts), do: Triple.values(triple, opts) def values({_, _, _, _} = quad, opts), do: Quad.values(quad, opts) @@ -173,7 +175,7 @@ defmodule RDF.Statement do {"S", :p, 42, ~I} """ - @spec map(t, term_mapping()) :: Triple.t_values() | Quad.t_values() | nil | nil + @spec map(t, term_mapping()) :: Triple.mapping_value() | Quad.mapping_value() | nil | nil def map(statement, fun) def map({_, _, _} = triple, fun), do: RDF.Triple.map(triple, fun) def map({_, _, _, _} = quad, fun), do: RDF.Quad.map(quad, fun) diff --git a/lib/rdf/triple.ex b/lib/rdf/triple.ex index 4c235d2..5bd576d 100644 --- a/lib/rdf/triple.ex +++ b/lib/rdf/triple.ex @@ -10,14 +10,16 @@ defmodule RDF.Triple do @type t :: {Statement.subject(), Statement.predicate(), Statement.object()} - @type coercible_t :: + @type coercible :: { Statement.coercible_subject(), Statement.coercible_predicate(), Statement.coercible_object() } - @type t_values :: {String.t(), String.t(), any} + @type mapping_value :: {String.t(), String.t(), any} + # deprecated: This will be removed in v0.11. + @type t_values :: mapping_value @doc """ Creates a `RDF.Triple` with proper RDF values. @@ -82,7 +84,7 @@ defmodule RDF.Triple do iex> RDF.Triple.new {EX.S, :p, 42}, RDF.PropertyMap.new(p: EX.p) {RDF.iri("http://example.com/S"), RDF.iri("http://example.com/p"), RDF.literal(42)} """ - @spec new(Statement.coercible_t(), PropertyMap.t() | nil) :: t + @spec new(Statement.coercible(), PropertyMap.t() | nil) :: t def new(statement, property_map \\ nil) def new({subject, predicate, object}, property_map), @@ -109,7 +111,7 @@ defmodule RDF.Triple do {"http://example.com/S", :p, 42} """ - @spec values(t, keyword) :: t_values | nil + @spec values(t, keyword) :: mapping_value | nil def values(triple, opts \\ []) do if property_map = PropertyMap.from_opts(opts) do map(triple, Statement.default_property_mapping(property_map)) @@ -139,7 +141,7 @@ defmodule RDF.Triple do {"S", "p", 42} """ - @spec map(t, Statement.term_mapping()) :: t_values | nil + @spec map(t, Statement.term_mapping()) :: mapping_value | nil def map({subject, predicate, object}, fun) do with subject_value when not is_nil(subject_value) <- fun.({:subject, subject}), predicate_value when not is_nil(predicate_value) <- fun.({:predicate, predicate}),