Casting from strings and/or inferring datatypes?

Suppose I have the following:

```
@prefix string: <http://www.w3.org/2000/10/swap/string#> .
@prefix ex: <https://example.org/> .

ex:a ex:date "2021-09" .

{
  ?x ex:date ?d
  . (?d "^\\d{4}-(\\d{2})$") string:scrape ?m
} => { 
  ?x ex:month ?m
}
.
```

Running this through a reasoner gives me:

```
@prefix ex: <https://example.org/> .

ex:a ex:month "09" .

```

But supposed instead I wanted:

```
@prefix ex: <https://example.org/> .

ex:a ex:month 9 .

```

or:

```
@prefix ex: <https://example.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:a ex:month “--09”^^xsd:gMonth .

```

Is this possible? 

Specifically, are there builtins or other mechanisms for casting a string to another datatype?

Received on Saturday, 4 September 2021 23:25:42 UTC