@@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
45 , getDefaultReferenceODT
45 , getDefaultReferenceODT
46 , newStdGen
46 , newStdGen
47 , newUniqueHash
47 , newUniqueHash
49 , readFileLazy
48 , readFileLazy
50 , readFileUTF8
49 , readFileUTF8
51 , readDataFile
50 , readDataFile
@@ -97,7 +96,6 @@ data PandocActionF nxt =
97 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
96 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
98 | NewStdGen (StdGen -> nxt)
97 | NewStdGen (StdGen -> nxt)
99 | NewUniqueHash (Int -> nxt)
98 | NewUniqueHash (Int -> nxt)
100− | ReadFileStrict FilePath (B.ByteString -> nxt)
101 | ReadFileLazy FilePath (BL.ByteString -> nxt)
99 | ReadFileLazy FilePath (BL.ByteString -> nxt)
102 | ReadFileUTF8 FilePath (String -> nxt)
100 | ReadFileUTF8 FilePath (String -> nxt)
103 | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt)
101 | ReadDataFile (Maybe FilePath) FilePath (B.ByteString -> nxt)
@@ -133,9 +131,6 @@ newStdGen = liftF $ NewStdGen id
133newUniqueHash :: PandocAction Int
131newUniqueHash :: PandocAction Int
134newUniqueHash = liftF $ NewUniqueHash id
132newUniqueHash = liftF $ NewUniqueHash id
136−readFileStrict :: FilePath -> PandocAction B.ByteString
137−readFileStrict fp = liftF $ ReadFileStrict fp id
139readFileLazy :: FilePath -> PandocAction BL.ByteString
134readFileLazy :: FilePath -> PandocAction BL.ByteString
140readFileLazy fp = liftF $ ReadFileLazy fp id
135readFileLazy fp = liftF $ ReadFileLazy fp id
@@ -176,7 +171,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
176 IO.getDefaultReferenceODT mfp >>= runIO . f
171 IO.getDefaultReferenceODT mfp >>= runIO . f
177runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
172runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
178runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
173runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
179−runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
180runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
174runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
181runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
175runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
182runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f
176runIO (Free (ReadDataFile mfp fp f)) = IO.readDataFile mfp fp >>= runIO . f
@@ -242,11 +236,6 @@ runTest (Free (NewUniqueHash f)) = do
242 modify $ \st -> st { stUniqStore = us }
236 modify $ \st -> st { stUniqStore = us }
243 return u >>= runTest . f
237 return u >>= runTest . f
244 _ -> M.fail "uniq store ran out of elements"
238 _ -> M.fail "uniq store ran out of elements"
245−runTest (Free (ReadFileStrict fp f)) = do
246− fps <- asks envFiles
247− case lookup fp fps of
248− Just bs -> return bs >>= runTest . f
249− Nothing -> error "openFile: does not exist"
250runTest (Free (ReadFileLazy fp f)) = do
239runTest (Free (ReadFileLazy fp f)) = do
251 fps <- asks envFiles
240 fps <- asks envFiles
252 case lookup fp fps of
241 case lookup fp fps of
@@ -269,7 +258,7 @@ runTest (Free (ReadDataFile Nothing "reference.odt" f)) = do
269 runTest . f
258 runTest . f
270runTest (Free (ReadDataFile Nothing fname f)) = do
259runTest (Free (ReadDataFile Nothing fname f)) = do
271 let fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
260 let fname' = if fname == "MANUAL.txt" then fname else "data" </> fname
272− runTest (readFileStrict fname') >>= runTest . f
261+ runTest (BL.toStrict <$> readFileLazy fname') >>= runTest . f
273runTest (Free (ReadDataFile (Just userDir) fname f)) = do
262runTest (Free (ReadDataFile (Just userDir) fname f)) = do
274 userDirFiles <- asks envUserDataDir
263 userDirFiles <- asks envUserDataDir
275 case lookup (userDir </> fname) userDirFiles of
264 case lookup (userDir </> fname) userDirFiles of