Copyright | Travis Whitaker 2016 |
---|---|
License | MIT |
Maintainer | pi.boy.travis@gmail.com |
Stability | Provisional |
Portability | Portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Data.RDF.Types
Contents
Description
This module provides types for representing RDF data based on the abstract syntax described in RDF 1.1 Concepts and Abstract Syntax.
- data RDFGraph = RDFGraph {
- rdfLabel :: !(Maybe IRI)
- rdfTriples :: [Triple]
- data Quad = Quad {
- quadTriple :: !Triple
- quadGraph :: !(Maybe IRI)
- data Triple = Triple !Subject !Predicate !Object
- data Subject
- newtype Predicate = Predicate {
- unPredicate :: IRI
- data Object
- newtype BlankNode = BlankNode {
- unBlankNode :: Text
- data Literal = Literal {
- litString :: !Text
- litType :: !LiteralType
- data LiteralType
- data IRI = IRI {}
- data IRIAuth = IRIAuth {}
Graphs
A contiguous RDF graph with optional label. Note that a contiguous graph within an RDF data set will not appear as a single contiguous graph to this library if the graph's constituent triples are not contiguous in the original data set. This strategy allows for incremental processing of RDF data in constant space.
Constructors
RDFGraph | |
Fields
|
An RDF quad, i.e. a triple belonging to a named graph.
An RDF triple.
Triple Components
An RDF subject, i.e. either an IRI
or a BlankNode
.
This type has an IsString
instance, allowing string literals to be
interpreted as Subject
s with -XOverloadedStrings
, like so:
>>>
"<http://example.com> :: Subject
IRISubject (IRI (...))>>>
"_:some-node" :: Subject
BlankSubject (BlankNode {unBlankNode = "some-node"})
Constructors
IRISubject !IRI | |
BlankSubject !BlankNode |
Instances
Eq Subject # | |
Ord Subject # | |
Read Subject # | |
Show Subject # | |
IsString Subject # | This instance uses |
Generic Subject # | |
NFData Subject # | |
type Rep Subject # | |
An RDF predicate.
This type has an IsString
instance, allowing string literals to be
interpreted as Predicate
s with -XOverloadedStrings
, like so:
>>>
"<http://example.com>" :: Predicate
Predicate {unPredicate = IRI (...)}
Constructors
Predicate | |
Fields
|
Instances
Eq Predicate # | |
Ord Predicate # | |
Read Predicate # | |
Show Predicate # | |
IsString Predicate # | This instance uses |
Generic Predicate # | |
NFData Predicate # | |
type Rep Predicate # | |
An RDF object, i.e. either an IRI
, a Literal
, or a BlankNode
.
This type has an IsString
instance, allowing string literals to be
interpreted as Object
s with -XOverloadedStrings
, like so:
>>>
"<http://example.com>" :: Object
IRIObject (IRI (...))>>>
"_:some-node" :: Object
BlankObject (BlankNode {unBlankNode = "some-node"})>>>
"computer" :: Object
LiteralObject (Literal {litString = "computer", litType = LiteralUntyped})
The precedence for literal interpretation is IRI > BlankNode > Literal. To
force a literal that is also a valid blank node label or IRI to be
interpreted as a LiteralObject
, wrap it in an extra set of double quotes:
>>>
"\"_:some-node\"" :: Object
LiteralObject (Literal {litString = "_:some-node", litType = LiteralUntyped})
Constructors
IRIObject !IRI | |
BlankObject !BlankNode | |
LiteralObject !Literal |
Instances
Eq Object # | |
Ord Object # | |
Read Object # | |
Show Object # | |
IsString Object # | This instance uses |
Generic Object # | |
NFData Object # | |
type Rep Object # | |
Terms
A blank node with its local label, without the preceeding "_:". Other programs processing RDF are permitted to discard these node labels, i.e. all blank node labels are local to a specific representation of an RDF data set.
This type has an IsString
instance, allowing string literals to be
interpreted as BlankNode
s with -XOverloadedStrings
, like so:
>>>
"_:some-node" :: BlankNode
BlankNode {unBlankNode = "some-node"}
Constructors
BlankNode | |
Fields
|
Instances
Eq BlankNode # | |
Ord BlankNode # | |
Read BlankNode # | |
Show BlankNode # | |
IsString BlankNode # | This instance uses |
Generic BlankNode # | |
NFData BlankNode # | |
type Rep BlankNode # | |
An RDF literal. As stipulated by the RDF standard, the litType
is merely
metadata; all RDF processing programs must try to handle literals that are
ill-typed.
This type has an IsString
instance, allowing string literals to be
interpreted as Literal
s with -XOverloadedStrings
, like so:
>>>
"computer" :: Literal
Literal {litString = "computer", litType = LiteralUntyped}
For untyped literals the extra double quotes are not required. They are required for typed literals:
>>>
"\"computer\"@en" :: Literal
Literal {litString = "computer", litType = LiteralLangType "en"}
>>>
"\"computer\"^^<http://computer.machine/machine>" :: Literal
Literal { litString = "computer", litType = LiteralIRIType (...)}
Constructors
Literal | |
Fields
|
Instances
Eq Literal # | |
Ord Literal # | |
Read Literal # | |
Show Literal # | |
IsString Literal # | This instance uses |
Generic Literal # | |
NFData Literal # | |
type Rep Literal # | |
data LiteralType #
An RDF literal type. As stipulated by the RDF standard, this is merely metadata; all RDF processing programs must try to handle literals that are ill-typed.
Constructors
LiteralIRIType !IRI | |
LiteralLangType !Text | |
LiteralUntyped |
Instances
IRIs
An Internationalized Resource Identifier. This library preferentially follows RFC 3987 over the RDF 1.1 specification, as the two standards disagree about precisely what constitutes an IRI. A notable exception is the handling of IRI fragments; this library follows the RDF 1.1 specification, allowing IRI fragments to occur in absolute IRIs, even though this is expressly prohibited by RFC 3987.
Unlike the network-uri
package's behavior with URI fields, this library
does not include the sentinel tokens in the parsed fields. For example,
when parsing http://example.com
, network-uri
will provide the string
http:
as the scheme, while this library will provide http
as the
scheme.
This type has an IsString
instnace, allowing string literals to be
interpreted as IRI
s with -XOverloadedStrings
, like so:
>>>
"http://example.com" :: IRI
IRI { iriScheme = "http" , iriAuth = Just (IRIAuth { iriUser = Nothing , iriHost = "example.com" , iriPort = Nothing }) , iriPath = "" , iriQuery = Nothing , iriFragment = Nothing }
Constructors
IRI | |
Fields
|
Instances
Eq IRI # | |
Ord IRI # | |
Read IRI # | |
Show IRI # | |
IsString IRI # | This instance uses |
Generic IRI # | |
NFData IRI # | |
type Rep IRI # | |
An IRI Authority, as described by RFC 3987.
Constructors
IRIAuth | |