module Rdf_dt:sig..end
A value can be an error, and propagated in computations.
type error =
| |
Type_error of |
(* |
The value has not the given expected "type"
| *) |
| |
Invalid_literal of |
(* |
Invalid literal: bad integer string for an integer, ...
| *) |
| |
Exception of |
(* |
To keep the original exception which resulted in an error.
| *) |
type value =
| |
Err of |
(* |
Value is an error
| *) |
| |
Blank of |
(* |
A blank node with its label
| *) |
| |
Iri of |
(* |
An URI.
| *) |
| |
String of |
(* |
A string literal.
| *) |
| |
Int of |
(* |
An integer.
| *) |
| |
Float of |
(* |
A decimal, float or double.
| *) |
| |
Bool of |
(* |
A Boolean.
| *) |
| |
Datetime of |
(* |
A datetime.
| *) |
| |
Ltrl of |
(* |
A literal string with an optional language tag.
| *) |
| |
Ltrdt of |
(* |
A literal value with a specified datatype.
| *) |
exception Error of error
val error : error -> 'aRdf_dt.Error exception with the given error.val date_fmt : stringval string_of_value : value -> stringmodule ValueOrdered:sig..end
module VMap:Map.Swith type key = value
module VSet:Set.Swith type elt = value
val string_of_error : error -> stringval iri : Rdf_uri.uri -> value -> valueiri base v returns a Iri value, ensure the given value is
an URI. If it is a literal string, convert it to an URI, eventually
appending to the base uri if the string expresses a relative URI.val datatype : value -> valuedatatype v returns the URI of the datatype of the value.
If v is Err, Blank or Iri, return Err.val string_literal : value -> string * string optionstring_literal v returns a pair (string, optional language tag) if
v is String of Ltrl. Else return Err.val string : value -> valuestring v returns a String value, converting any value
to a string, except Err and Blank for which Err is returned.val int : value -> valueint v returns a Int value, trying to convert literal values
to an integer. Return Err if v is Err, Blank or Iri, or
if the literal value could not be converted to an integer. Floats
are truncated.val float : value -> valueRdf_dt.int but for floats.val bool : value -> valueRdf_dt.int but for booleans.
Bool true, String "true", String "1", Int n with n<>0 and Float f when f is not nan nor zero evaluate
to Bool true.
Bool false, String "false", String "0", Int 0 and Float f when f is nan or zero evaluate to
Bool false.
Any other value evaluates to Err.val datetime : value -> valuedatetime v returns a Datetime, if possible. String literals are converted if
possible; else Err is returned.val ltrl : value -> value
val numeric : value -> valueInt or else to a Float,
if the value is not already Int or Float.val of_literal : Rdf_node.literal -> valueof_literal lit returns a value from a literal node.val of_node : Rdf_node.node -> valueof_node node returns a value from an RDF node.val to_node : value -> Rdf_node.nodeto_node v converts the given value to an RDF node.
If v is Error e, then exception e is raised.