Skip to content

Commit 5455df5

Browse files
authored
Merge pull request #96 from haskell-works/use-FilePath-type-in-place-of-String
Use FilePath type in place of String
2 parents f344842 + 6ef021b commit 5455df5

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

app/App/Naive.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import qualified Data.ByteString as BS
2323

2424
-- | Load an XML file into memory and return a raw cursor initialised to the
2525
-- start of the XML document.
26-
loadSlowCursor :: String -> IO SlowCursor
26+
loadSlowCursor :: FilePath -> IO SlowCursor
2727
loadSlowCursor path = do
2828
!bs <- BS.readFile path
2929
let !cursor = fromByteString bs :: SlowCursor
3030
return cursor
3131

3232
-- | Load an XML file into memory and return a query-optimised cursor initialised
3333
-- to the start of the XML document.
34-
loadFastCursor :: String -> IO FastCursor
34+
loadFastCursor :: FilePath -> IO FastCursor
3535
loadFastCursor filename = do
3636
-- Load the XML file into memory as a raw cursor.
3737
-- The raw XML data is `text`, and `ib` and `bp` are the indexes.

src/HaskellWorks/Data/Xml/Succinct/Cursor/Load.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ import qualified Data.ByteString as BS
1212

1313
-- | Load an XML file into memory and return a raw cursor initialised to the
1414
-- start of the XML document.
15-
loadSlowCursor :: String -> IO SlowCursor
15+
loadSlowCursor :: FilePath -> IO SlowCursor
1616
loadSlowCursor = fmap byteStringAsSlowCursor . BS.readFile
1717

1818
-- | Load an XML file into memory and return a query-optimised cursor initialised
1919
-- to the start of the XML document.
20-
loadFastCursor :: String -> IO FastCursor
20+
loadFastCursor :: FilePath -> IO FastCursor
2121
loadFastCursor = fmap byteStringAsFastCursor . BS.readFile

src/HaskellWorks/Data/Xml/Succinct/Cursor/MMap.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import qualified Data.ByteString.Internal as BSI
2323
import qualified HaskellWorks.Data.Xml.Internal.ToIbBp64 as I
2424
import qualified System.IO.MMap as IO
2525

26-
mmapSlowCursor :: String -> IO SlowCursor
26+
mmapSlowCursor :: FilePath -> IO SlowCursor
2727
mmapSlowCursor filePath = do
2828
(fptr :: ForeignPtr Word8, offset, size) <- IO.mmapFileForeignPtr filePath IO.ReadOnly Nothing
2929
let !bs = BSI.fromForeignPtr (castForeignPtr fptr) offset size
@@ -38,7 +38,7 @@ mmapSlowCursor filePath = do
3838

3939
return cursor
4040

41-
mmapFastCursor :: String -> IO FastCursor
41+
mmapFastCursor :: FilePath -> IO FastCursor
4242
mmapFastCursor filename = do
4343
-- Load the XML file into memory as a raw cursor.
4444
-- The raw XML data is `text`, and `ib` and `bp` are the indexes.

src/HaskellWorks/Data/Xml/Succinct/Index.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,20 @@ instance (BP.BalancedParens w, Rank0 w, Rank1 w, Select1 v, TestBit w) => XmlInd
6565

6666
getIndexAt :: (BP.BalancedParens w, Rank0 w, Rank1 w, Select1 v, TestBit w) => XmlIndexState -> XmlCursor BS.ByteString v w -> XmlIndex
6767
getIndexAt state k = case uncons remainder of
68-
Just (!c, cs) | isElementStart c -> parseElem cs
69-
Just (!c, _ ) | isSpace c -> XmlIndexAttrList $ mapValuesFrom InAttrList (firstChild k)
70-
Just (!c, _ ) | isAttribute && isQuote c -> XmlIndexAttrValue remainder
71-
Just _ | isAttribute -> XmlIndexAttrName remainder
72-
Just _ -> XmlIndexValue remainder
73-
Nothing -> XmlIndexError "End of data"
68+
Just (!c, cs) | isElementStart c -> parseElem cs
69+
Just (!c, _ ) | isSpace c -> XmlIndexAttrList $ mapValuesFrom InAttrList (firstChild k)
70+
Just (!c, _ ) | isAttribute && isQuote c -> XmlIndexAttrValue remainder
71+
Just _ | isAttribute -> XmlIndexAttrName remainder
72+
Just _ -> XmlIndexValue remainder
73+
Nothing -> XmlIndexError "End of data"
7474
where remainder = remText k
7575
mapValuesFrom s = L.unfoldr (fmap (getIndexAt s &&& nextSibling))
7676
isAttribute = case state of
7777
InAttrList -> True
7878
InElement -> False
7979
Unknown -> case remText <$> parent k >>= uncons of
8080
Just (!c, _) | isSpace c -> True
81-
_ -> False
81+
_ -> False
8282

8383
parseElem bs =
8484
case ABC.parse parseXmlElement bs of

0 commit comments

Comments
 (0)