{-# Language OverloadedStrings #-}

--------------------------------------------------------------------------------
--  See end of this file for licence information.
--------------------------------------------------------------------------------
-- |
--  Module      :  Swish.RDF.Vocabulary.RDF
--  Copyright   :  (c) 2003, Graham Klyne, 2009 Vasili I Galchin, 2011 Douglas Burke
--  License     :  GPL V2
--
--  Maintainer  :  Douglas Burke
--  Stability   :  experimental
--  Portability :  OverloadedStrings
--
--  This module defines some commonly used vocabulary terms from the
--  RDF (<http://www.w3.org/TR/rdf-syntax-grammar/>) and
--  RDF Schema (<http://www.w3.org/TR/rdf-schema/>) documents.
--
--------------------------------------------------------------------------------

module Swish.RDF.Vocabulary.RDF
    ( 
      -- * Namespaces
      
      namespaceRDF
    , namespaceRDFS
    
    -- * RDF terms                                          
    --                                          
    -- | These terms are described in <http://www.w3.org/TR/rdf-syntax-grammar/>;                                          
    -- the version used is \"W3C Recommendation 10 February 2004\", <http://www.w3.org/TR/2004/REC-rdf-syntax-grammar-20040210/>.
    --                                          
    -- Some terms are listed within the RDF Schema terms below since their definition                                            
    -- is given within the RDF Schema document.                                          
    --                                          
    , rdfRDF                                          
    , rdfDescription      
    , rdfID
    , rdfAbout
    , rdfParseType
    , rdfResource
    , rdfLi
    , rdfNodeID
    , rdfDatatype
    , rdf1, rdf2, rdfn
    -- * RDF Schema terms
    --
    -- | These are defined by <http://www.w3.org/TR/rdf-schema/>; the version
    -- used is \"W3C Recommendation 10 February 2004\", <http://www.w3.org/TR/2004/REC-rdf-schema-20040210/>.
                  
    -- ** Classes
    --
    -- | See the \"Classes\" section at <http://www.w3.org/TR/rdf-schema/#ch_classes> for more information.
    , rdfsResource
    , rdfsClass
    , rdfsLiteral
    , rdfsDatatype
    , rdfXMLLiteral
    , rdfProperty
    
    -- ** Properties
    --                                 
    -- | See the \"Properties\" section at <http://www.w3.org/TR/rdf-schema/#ch_classes> for more information.
    , rdfsRange
    , rdfsDomain
    , rdfType
    , rdfsSubClassOf
    , rdfsSubPropertyOf
    , rdfsLabel
    , rdfsComment
    -- ** Containers
    --
    -- | See the \"Container Classes and Properties\" section at <http://www.w3.org/TR/rdf-schema/#ch_containervocab>.
    , rdfsContainer
    , rdfBag
    , rdfSeq                                 
    , rdfAlt  
    , rdfsContainerMembershipProperty
    , rdfsMember
    -- ** Collections
    --
    -- | See the \"Collections\" section at <http://www.w3.org/TR/rdf-schema/#ch_collectionvocab>.
    , rdfList    
    , rdfFirst
    , rdfRest 
    , rdfNil 
    -- ** Reification Vocabulary 
    --  
    -- | See the \"Reification Vocabulary\" section at <http://www.w3.org/TR/rdf-schema/#ch_reificationvocab>.
    , rdfStatement  
    , rdfSubject  
    , rdfPredicate  
    , rdfObject  
    -- ** Utility Properties 
    --  
    -- | See the \"Utility Properties\" section at <http://www.w3.org/TR/rdf-schema/#ch_utilvocab>.
    , rdfsSeeAlso
    , rdfsIsDefinedBy
    , rdfValue  
      
    )
where

import Swish.Namespace (Namespace, makeNamespace, ScopedName, makeNSScopedName)
import Swish.QName (LName, newLName)

import Data.Maybe (fromMaybe, fromJust)
import Data.Word (Word32)

import Network.URI (URI, parseURI)

import qualified Data.Text as T

------------------------------------------------------------
--  Namespaces
------------------------------------------------------------

rdfURI, rdfsURI :: URI
rdfURI :: URI
rdfURI = URI -> Maybe URI -> URI
forall a. a -> Maybe a -> a
fromMaybe ([Char] -> URI
forall a. HasCallStack => [Char] -> a
error [Char]
"Internal error processing RDF URI") (Maybe URI -> URI) -> Maybe URI -> URI
forall a b. (a -> b) -> a -> b
$ [Char] -> Maybe URI
parseURI [Char]
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
rdfsURI :: URI
rdfsURI = URI -> Maybe URI -> URI
forall a. a -> Maybe a -> a
fromMaybe ([Char] -> URI
forall a. HasCallStack => [Char] -> a
error [Char]
"Internal error processing RDFS URI") (Maybe URI -> URI) -> Maybe URI -> URI
forall a b. (a -> b) -> a -> b
$ [Char] -> Maybe URI
parseURI [Char]
"http://www.w3.org/2000/01/rdf-schema#"

-- | Maps @rdf@ to <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
namespaceRDF :: Namespace
namespaceRDF :: Namespace
namespaceRDF = Maybe Text -> URI -> Namespace
makeNamespace (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"rdf") URI
rdfURI

-- | Maps @rdfs@ to <http://www.w3.org/2000/01/rdf-schema#>.
namespaceRDFS :: Namespace
namespaceRDFS :: Namespace
namespaceRDFS = Maybe Text -> URI -> Namespace
makeNamespace (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"rdfs") URI
rdfsURI

------------------------------------------------------------
--  Terms
------------------------------------------------------------

toRDF, toRDFS :: LName -> ScopedName
toRDF :: LName -> ScopedName
toRDF  = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceRDF
toRDFS :: LName -> ScopedName
toRDFS = Namespace -> LName -> ScopedName
makeNSScopedName Namespace
namespaceRDFS

-- | @rdf:RDF@.
rdfRDF :: ScopedName
rdfRDF :: ScopedName
rdfRDF = LName -> ScopedName
toRDF LName
"RDF"

-- | @rdf:Description@.
rdfDescription :: ScopedName
rdfDescription :: ScopedName
rdfDescription = LName -> ScopedName
toRDF LName
"Description"
  
-- | @rdf:datatype@.
rdfDatatype   :: ScopedName
rdfDatatype :: ScopedName
rdfDatatype   = LName -> ScopedName
toRDF LName
"datatype"

-- | @rdf:resource@.
rdfResource   :: ScopedName
rdfResource :: ScopedName
rdfResource   = LName -> ScopedName
toRDF LName
"resource"

-- | @rdf:about@.
rdfAbout      :: ScopedName
rdfAbout :: ScopedName
rdfAbout      = LName -> ScopedName
toRDF LName
"about"

-- | @rdf:ID@.
rdfID         :: ScopedName
rdfID :: ScopedName
rdfID         = LName -> ScopedName
toRDF LName
"ID"

-- | @rdf:parseType@.
rdfParseType :: ScopedName
rdfParseType :: ScopedName
rdfParseType = LName -> ScopedName
toRDF LName
"parseType"

-- | @rdf:li@.
rdfLi :: ScopedName
rdfLi :: ScopedName
rdfLi = LName -> ScopedName
toRDF LName
"li"

-- | @rdf:nodeID@.
rdfNodeID :: ScopedName
rdfNodeID :: ScopedName
rdfNodeID = LName -> ScopedName
toRDF LName
"nodeID"

-- | Create a @rdf:_n@ entity.
--
-- There is no check that the argument is not 0, so it is
-- possible to create the un-defined label @rdf:_0@.
rdfn :: 
    Word32
    -> ScopedName
rdfn :: Word32 -> ScopedName
rdfn = LName -> ScopedName
toRDF (LName -> ScopedName) -> (Word32 -> LName) -> Word32 -> ScopedName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe LName -> LName
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe LName -> LName)
-> (Word32 -> Maybe LName) -> Word32 -> LName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Maybe LName
newLName (Text -> Maybe LName) -> (Word32 -> Text) -> Word32 -> Maybe LName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Char] -> Text
T.pack ([Char] -> Text) -> (Word32 -> [Char]) -> Word32 -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Char]
"_" [Char] -> [Char] -> [Char]
forall a. [a] -> [a] -> [a]
++) ([Char] -> [Char]) -> (Word32 -> [Char]) -> Word32 -> [Char]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> [Char]
forall a. Show a => a -> [Char]
show

-- | @rdf:_1@.
rdf1 :: ScopedName
rdf1 :: ScopedName
rdf1 = LName -> ScopedName
toRDF LName
"_1"

-- | @rdf:_2@.
rdf2 :: ScopedName
rdf2 :: ScopedName
rdf2 = LName -> ScopedName
toRDF LName
"_2"

-- | @rdf:first@ from <http://www.w3.org/TR/rdf-schema/#ch_first>.
rdfFirst      :: ScopedName
rdfFirst :: ScopedName
rdfFirst      = LName -> ScopedName
toRDF LName
"first"

-- | @rdf:rest@ from <http://www.w3.org/TR/rdf-schema/#ch_rest>.
rdfRest       :: ScopedName
rdfRest :: ScopedName
rdfRest       = LName -> ScopedName
toRDF LName
"rest"

-- | @rdf:nil@ from <http://www.w3.org/TR/rdf-schema/#ch_nil>.
rdfNil        :: ScopedName
rdfNil :: ScopedName
rdfNil        = LName -> ScopedName
toRDF LName
"nil"

-- | @rdf:type@ from <http://www.w3.org/TR/rdf-schema/#ch_type>.
rdfType       :: ScopedName
rdfType :: ScopedName
rdfType       = LName -> ScopedName
toRDF LName
"type"

-- | @rdf:Property@ from <http://www.w3.org/TR/rdf-schema/#ch_property>.
rdfProperty   :: ScopedName
rdfProperty :: ScopedName
rdfProperty   = LName -> ScopedName
toRDF LName
"Property"

-- | @rdf:XMLLiteral@ from <http://www.w3.org/TR/rdf-schema/#ch_xmlliteral>.
rdfXMLLiteral :: ScopedName
rdfXMLLiteral :: ScopedName
rdfXMLLiteral = LName -> ScopedName
toRDF LName
"XMLLiteral"

-- | @rdfs:Resource@ from <http://www.w3.org/TR/rdf-schema/#ch_resource>.
rdfsResource :: ScopedName
rdfsResource :: ScopedName
rdfsResource = LName -> ScopedName
toRDFS LName
"Resource"

-- | @rdfs:Class@ from <http://www.w3.org/TR/rdf-schema/#ch_class>.
rdfsClass :: ScopedName
rdfsClass :: ScopedName
rdfsClass = LName -> ScopedName
toRDFS LName
"Class"

-- | @rdfs:Literal@ from <http://www.w3.org/TR/rdf-schema/#ch_literal>.
rdfsLiteral :: ScopedName
rdfsLiteral :: ScopedName
rdfsLiteral = LName -> ScopedName
toRDFS LName
"Literal"

-- | @rdfs:Datatype@ from <http://www.w3.org/TR/rdf-schema/#ch_datatype>.
rdfsDatatype :: ScopedName
rdfsDatatype :: ScopedName
rdfsDatatype = LName -> ScopedName
toRDFS LName
"Datatype"

-- | @rdfs:label@ from <http://www.w3.org/TR/rdf-schema/#ch_label>.
rdfsLabel :: ScopedName
rdfsLabel :: ScopedName
rdfsLabel = LName -> ScopedName
toRDFS LName
"label"

-- | @rdfs:comment@ from <http://www.w3.org/TR/rdf-schema/#ch_comment>.
rdfsComment :: ScopedName
rdfsComment :: ScopedName
rdfsComment = LName -> ScopedName
toRDFS LName
"comment"

-- | @rdfs:range@ from <http://www.w3.org/TR/rdf-schema/#ch_range>.
rdfsRange :: ScopedName
rdfsRange :: ScopedName
rdfsRange = LName -> ScopedName
toRDFS LName
"range"

-- | @rdfs:domain@ from <http://www.w3.org/TR/rdf-schema/#ch_domain>.
rdfsDomain :: ScopedName
rdfsDomain :: ScopedName
rdfsDomain = LName -> ScopedName
toRDFS LName
"domain"

-- | @rdfs:subClassOf@ from <http://www.w3.org/TR/rdf-schema/#ch_subclassof>.
rdfsSubClassOf :: ScopedName
rdfsSubClassOf :: ScopedName
rdfsSubClassOf = LName -> ScopedName
toRDFS LName
"subClassOf"

-- | @rdfs:subPropertyOf@ from <http://www.w3.org/TR/rdf-schema/#ch_subpropertyof>.
rdfsSubPropertyOf :: ScopedName
rdfsSubPropertyOf :: ScopedName
rdfsSubPropertyOf = LName -> ScopedName
toRDFS LName
"subPropertyOf"

-- | @rdfs:Container@ from <http://www.w3.org/TR/rdf-schema/#ch_container>.
rdfsContainer :: ScopedName
rdfsContainer :: ScopedName
rdfsContainer = LName -> ScopedName
toRDFS LName
"Container"

-- | @rdf:Bag@ from <http://www.w3.org/TR/rdf-schema/#ch_bag>.
rdfBag :: ScopedName
rdfBag :: ScopedName
rdfBag = LName -> ScopedName
toRDF LName
"Bag"

-- | @rdf:Seq@ from <http://www.w3.org/TR/rdf-schema/#ch_seq>.
rdfSeq :: ScopedName
rdfSeq :: ScopedName
rdfSeq = LName -> ScopedName
toRDF LName
"Seq"

-- | @rdf:Alt@ from <http://www.w3.org/TR/rdf-schema/#ch_alt>.
rdfAlt :: ScopedName
rdfAlt :: ScopedName
rdfAlt = LName -> ScopedName
toRDF LName
"Alt"

-- | @rdfs:ContainerMembershipProperty@ from <http://www.w3.org/TR/rdf-schema/#ch_containermembershipproperty>.
rdfsContainerMembershipProperty :: ScopedName
rdfsContainerMembershipProperty :: ScopedName
rdfsContainerMembershipProperty = LName -> ScopedName
toRDFS LName
"ContainerMembershipProperty"

-- | @rdfs:member@ from <http://www.w3.org/TR/rdf-schema/#ch_member>.
rdfsMember :: ScopedName
rdfsMember :: ScopedName
rdfsMember    = LName -> ScopedName
toRDFS LName
"member"

-- | @rdf:List@ from <http://www.w3.org/TR/rdf-schema/#ch_list>.
rdfList :: ScopedName
rdfList :: ScopedName
rdfList = LName -> ScopedName
toRDF LName
"List"

-- | @rdf:Statement@ from <http://www.w3.org/TR/rdf-schema/#ch_statement>.
rdfStatement :: ScopedName
rdfStatement :: ScopedName
rdfStatement = LName -> ScopedName
toRDF LName
"Statement"

-- | @rdf:subject@ from <http://www.w3.org/TR/rdf-schema/#ch_subject>.
rdfSubject :: ScopedName
rdfSubject :: ScopedName
rdfSubject = LName -> ScopedName
toRDF LName
"subject"

-- | @rdf:predicate@ from <http://www.w3.org/TR/rdf-schema/#ch_predicate>.
rdfPredicate :: ScopedName
rdfPredicate :: ScopedName
rdfPredicate = LName -> ScopedName
toRDF LName
"subject"

-- | @rdf:object@ from <http://www.w3.org/TR/rdf-schema/#ch_object>.
rdfObject :: ScopedName
rdfObject :: ScopedName
rdfObject = LName -> ScopedName
toRDF LName
"object"

-- | @rdfs:seeAlso@ from <http://www.w3.org/TR/rdf-schema/#ch_seealso>.
rdfsSeeAlso :: ScopedName
rdfsSeeAlso :: ScopedName
rdfsSeeAlso = LName -> ScopedName
toRDFS LName
"seeAlso"

-- | @rdfs:isDefinedBy@ from <http://www.w3.org/TR/rdf-schema/#ch_isdefinedby>.
rdfsIsDefinedBy :: ScopedName
rdfsIsDefinedBy :: ScopedName
rdfsIsDefinedBy = LName -> ScopedName
toRDFS LName
"isDefinedBy"

-- | @rdf:value@ from <http://www.w3.org/TR/rdf-schema/#ch_value>.
rdfValue :: ScopedName
rdfValue :: ScopedName
rdfValue = LName -> ScopedName
toRDF LName
"value"

--------------------------------------------------------------------------------
--
--  Copyright (c) 2011 Douglas Burke
--  All rights reserved.
--
--  This file is part of Swish.
--
--  Swish is free software; you can redistribute it and/or modify
--  it under the terms of the GNU General Public License as published by
--  the Free Software Foundation; either version 2 of the License, or
--  (at your option) any later version.
--
--  Swish is distributed in the hope that it will be useful,
--  but WITHOUT ANY WARRANTY; without even the implied warranty of
--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--  GNU General Public License for more details.
--
--  You should have received a copy of the GNU General Public License
--  along with Swish; if not, write to:
--    The Free Software Foundation, Inc.,
--    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--
--------------------------------------------------------------------------------