# IRIs

RDF.ex follows the RDF specs and supports IRIs (opens new window), an internationalized generalization of URIs, permitting a wider range of Unicode characters. They are represented with the RDF.IRI structure and can be constructed either with RDF.IRI.new/1 or RDF.IRI.new!/1, the latter of which additionally validates, that the given IRI is actually a valid absolute IRI or raises an exception otherwise.

RDF.IRI.new("http://www.example.com/foo")
RDF.IRI.new!("http://www.example.com/foo")

The RDF module defines the alias functions RDF.iri/1 and RDF.iri!/1 delegating to the resp. new function:

RDF.iri("http://www.example.com/foo")
RDF.iri!("http://www.example.com/foo")

Besides being a little shorter than RDF.IRI.new and better importable, their usage will automatically benefit from any future IRI creation optimizations and is therefore recommended over the original functions.

A literal IRI can also be written with the ~I sigil or the ~i which supports string interpolation:

import RDF.Sigils

~I<http://www.example.com/foo>

~i<http://www.example.com/#{fun(args)}>

TIP

Instead of the import RDF.Sigils required to be able to use the sigils defined by RDF.ex, you can also just write use RDF which combines the most important imports and aliases.

But there's an even shorter notation for IRI literals.