Anonymous avatar Anonymous committed 207e5f7

HLint updates

Comments (0)

Files changed (2)

src/Swish/RDF/Parser/N3.hs

 -}
 
 singleQuoted :: N3Parser T.Text
-singleQuoted = T.pack <$> (bracket sQuot sQuot $ many n3Character)
+singleQuoted = T.pack <$> bracket sQuot sQuot (many n3Character)
     
 {-
 tripleQUoted ::=	"""[^"\\]*(?:(?:\\.|"(?!""))[^"\\]*)*"""
   ignore $ char '"'
   mb <- optional (char '"')
   case mb of
-    Just _ -> return $ "\"\""
-    _      -> return $ "\""
+    Just _ -> return "\"\""
+    _      -> return "\""
 
 _multiQuote :: N3Parser T.Text
 _multiQuote = do
-  mq <- optional (oneOrTwo)
+  mq <- optional oneOrTwo
   r <- noneOf "\"\\"
   return $ fromMaybe T.empty mq `T.snoc` r
                 
 noError :: String
 noError = ""
 
--- check that the 
---    parseNT input == parseNT (formatGraph (parse NT input))
---
-roundTrip :: String -> T.Text -> Test
-roundTrip lbl inp = 
+-- | Take the input graph and parse it (the first
+--   graph), then convert this back to text and parse
+--   the result, to give the second graph. The
+--   two strings are the errors from the parses,
+--   if any.
+doRoundTrip :: T.Text -> (RDFGraph, RDFGraph, String, String)
+doRoundTrip inp =
   let (pErr1, pGr1) = case parseNT inp of
         Right g -> (noError, g)
         Left  s -> (s, emptyRDFGraph)
       (pErr2, pGr2) = case parseNT inp2 of
         Right g -> (noError, g)
         Left  s -> (s, emptyRDFGraph)
+
+  in (pGr1, pGr2, pErr1, pErr2)
+
+-- check that the 
+--    parseNT input == parseNT (formatGraph (parse NT input))
+--
+roundTrip :: String -> T.Text -> Test
+roundTrip lbl inp = 
+  let (pGr1, pGr2, pErr1, pErr2) = doRoundTrip inp
         
   in TestList
     [ TestCase (assertEqual ("roundTrip-parsing1:"++lbl) noError pErr1)
 
 roundTripTF :: String -> T.Text -> TF.Test
 roundTripTF lbl inp = 
-  let (pErr1, pGr1) = case parseNT inp of
-        Right g -> (noError, g)
-        Left  s -> (s, emptyRDFGraph)
-        
-      inp2 = formatGraphAsLazyText pGr1
-      
-      (pErr2, pGr2) = case parseNT inp2 of
-        Right g -> (noError, g)
-        Left  s -> (s, emptyRDFGraph)
+  let (pGr1, pGr2, pErr1, pErr2) = doRoundTrip inp
         
   in TF.testGroup ("roundTrip:" ++ lbl)
      [ TF.testCase "parsing1" (noError @=? pErr1)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.