Add RDF.Datatype.cast/1

This commit is contained in:
Marcel Otto 2018-09-09 15:26:32 +02:00
parent f4b9b0f434
commit b0e4e5327e
2 changed files with 13 additions and 1 deletions

View file

@ -16,6 +16,8 @@ This project adheres to [Semantic Versioning](http://semver.org/) and
literals in Turtle encoder
- `RDF.Numeric` with a list of all numeric datatypes and shared functions for
all numeric literals, eg. arithmetic functions
- `RDF.Datatype.cast/1` for casting between `RDF.Literal`s as specified in the
XSD spec
- the logical operators and the Effective Boolean Value (EBV) coercion algorithm
from the XPath and SPARQL specs on `RDF.Boolean`
- `RDF.DateTime.now/0`

View file

@ -35,7 +35,7 @@ defmodule RDF.Datatype do
@doc """
Produces the canonical form of a `RDF.Literal`.
"""
@callback canonical(literal :: RDF.Literal.t) :: RDF.Literal.t
@callback canonical(RDF.Literal.t) :: RDF.Literal.t
@doc """
Converts a value into a proper native value.
@ -51,6 +51,16 @@ defmodule RDF.Datatype do
"""
@callback convert(any, keyword) :: any
@doc """
Casts a literal of another datatype into a literal of the datatype the function is implemented on.
If the given literal is invalid or can not be converted into this datatype
`nil` is returned.
"""
@callback cast(RDF.Literal.t) :: RDF.Literal.t
@doc """
Determines if the value of a `RDF.Literal` is a member of lexical value space of its datatype.
"""