Commits

Doug Burke committed f24ec4b

Removed QName constructor

  • Participants
  • Parent commits 4478444

Comments (0)

Files changed (5)

 0.5.0.0:
 
-  - Changes to ScopedName to provide a significant reduction in the time
-    taken to write out a graph. As this is an experimental change the
-    record fields are no longer exported (to avoid exposing internal
-    details that may change).
-  
+  - The constructors for ScopedName and QName have been removed in
+    order to allow a simple experimental optimisation (partly added in
+    0.4.0.0).
+
 0.4.0.0:
 
   - Use polyparse rather than parsec-2 for parsing. As part of this,

File Swish/RDF/N3Parser.hs

     , nullScopedName
     )
 
-import Swish.Utils.QName (QName(..))
+import Swish.Utils.QName (QName)
 
 import Swish.RDF.Vocabulary
     ( langName

File Swish/Utils/Namespace.hs

     )
     where
 
-import Swish.Utils.QName (QName(..), newQName, getQNameURI, getNamespace, getLocalName)
+import Swish.Utils.QName (QName, newQName, getQNameURI, getNamespace, getLocalName)
 import Swish.Utils.LookupMap (LookupEntryClass(..))
 
 import Data.Monoid (Monoid(..))
 -- |Construct a ScopedName from prefix, URI and local name
 makeScopedName :: Maybe T.Text -> URI -> T.Text -> ScopedName
 makeScopedName pre nsuri local =
-  let l = T.unpack local
-      uristr = show nsuri ++ l
-      uri = fromMaybe (error ("Unable to parse URI from: '" ++ show nsuri ++ "' + '" ++ l ++ "'")) (parseURIReference uristr)
-      qn = QName uri nsuri local
-      
-  in ScopedName qn (Namespace pre nsuri) local
+  ScopedName (newQName nsuri local) (Namespace pre nsuri) local
 
 {-
 TODO: should just pass URIs around.

File Swish/Utils/QName.hs

 -- the tests really should be using relative URIs in this case).
 
 module Swish.Utils.QName
-    ( QName(..)
+    ( QName
     , newQName
     , qnameFromURI
     , getNamespace
     where
 
 import System.Directory (canonicalizePath)
--- import System.FilePath (splitDirectories)
 
-import Network.URI (URI(..), URIAuth(..), parseURIReference)
+import Network.URI (URI(..), URIAuth(..)
+                    , parseURIReference)
 
 import Data.String (IsString(..))
--- import Data.Char (isAlpha, isAlphaNum)
 import Data.Maybe (fromMaybe)
--- import Data.List (intercalate)
 
 import qualified Data.Text as T
 
         (up2,ur2) = splitAt n u2
   -}
   
+-- The format of show QName may well change to remove the <>
 instance Show QName where
     show (QName u _ _) = "<" ++ show u ++ ">"
 
   let l   = T.unpack local
       uristr = show ns ++ l
       uri = fromMaybe (error ("Unable to parse URI from: '" ++ show ns ++ "' + '" ++ l ++ "'")) (parseURIReference uristr)
+  
+  {- the following does not work since the semantics of relativeTo do not match the required
+     behavior here.  It may well be better to do something like the following, writing a replacement for
+     relativeTo, but leave that for a later date.
+  
+  let l   = T.unpack local
+      luri = fromMaybe (error ("Unable to parse local name as a URI reference: '" ++ l ++ "'")) (parseRelativeReference l)
+      uri = fromMaybe (error ("Unable to combine " ++ show ns ++ " with " ++ l)) $ luri `relativeTo` ns
+  -}
+      
   in QName uri ns local
 
 {-
       
     e -> error $ "Unexpected: uri=" ++ show uri ++ " has fragment='" ++ show e ++ "'" 
 
+-- | Return the URI of the namespace stored in the QName.
+-- This does not contain the local component.
+--
 getNamespace :: QName -> URI
 getNamespace = qnNsuri
 
+-- | Return the local component of the QName.
 getLocalName :: QName -> T.Text
 getLocalName = qnLocal
 
+-- | Returns the full URI of the QName (ie the combination of the
+-- namespace and local components).
 getQNameURI :: QName -> URI
 getQNameURI = qnURI
 
   .
   Changes:
   .
-  [Version 0.5.0.0] Changes to @ScopedName@ to provide significant reduction
-  in time to write out a graph. This should be considered an experimental change;
-  as a consequence the record fields for ScopedName are no longer exported.
+  [Version 0.5.0.0] The constructors for @ScopedName@ and @QName@ have been
+  removed to hide some experimental optimisations (partly added in 0.4.0.0).
   .
   [Version 0.4.0.0] Moving to using polyparse for parsing and @Text@ rather than
   @String@ where appropriate. Use of @URI@ and @Maybe Text@ rather than @String@ in the @Namespace@