aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJesse Rosenthal <jrosenthal@jhu.edu>2016-11-19 05:42:00 -0500
committerJohn MacFarlane <jgm@berkeley.edu>2017-01-25 17:07:39 +0100
commitc9e67163fd08f7eb1ef18aed47d7fab4614653b6 (patch)
treebf6e9d4d2b97aaab03db85b46568c244498b37f9 /src/Text
parent8b144db6e575e56205de881d8ae233fe2ff828da (diff)
downloadpandoc-c9e67163fd08f7eb1ef18aed47d7fab4614653b6.tar.gz
Remove IO UUID functions.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Free.hs16
-rw-r--r--src/Text/Pandoc/Writers/EPUB.hs3
2 files changed, 2 insertions, 17 deletions
diff --git a/src/Text/Pandoc/Free.hs b/src/Text/Pandoc/Free.hs
index 33cb50c88..071482e32 100644
--- a/src/Text/Pandoc/Free.hs
+++ b/src/Text/Pandoc/Free.hs
@@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
, getDefaultReferenceODT
, newStdGen
, newUniqueHash
- , newUUID
, readFileStrict
, readFileLazy
, readFileUTF8
@@ -81,8 +80,6 @@ import qualified Data.ByteString.Lazy as BL
import Control.Monad.Free
import qualified Control.Exception as E
import qualified System.Environment as IO (lookupEnv)
-import Text.Pandoc.UUID
-import qualified Text.Pandoc.UUID as IO (getRandomUUID)
import qualified Text.Pandoc.UTF8 as UTF8 (readFile, toString)
import System.FilePath.Glob (match, compile)
import System.FilePath ((</>))
@@ -100,7 +97,6 @@ data PandocActionF nxt =
| GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
| NewStdGen (StdGen -> nxt)
| NewUniqueHash (Int -> nxt)
- | NewUUID (UUID -> nxt)
| ReadFileStrict FilePath (B.ByteString -> nxt)
| ReadFileLazy FilePath (BL.ByteString -> nxt)
| ReadFileUTF8 FilePath (String -> nxt)
@@ -137,9 +133,6 @@ newStdGen = liftF $ NewStdGen id
newUniqueHash :: PandocAction Int
newUniqueHash = liftF $ NewUniqueHash id
-newUUID :: PandocAction UUID
-newUUID = liftF $ NewUUID id
-
readFileStrict :: FilePath -> PandocAction B.ByteString
readFileStrict fp = liftF $ ReadFileStrict fp id
@@ -183,7 +176,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
IO.getDefaultReferenceODT mfp >>= runIO . f
runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
-runIO (Free (NewUUID f)) = IO.getRandomUUID >>= runIO . f
runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
@@ -250,14 +242,6 @@ runTest (Free (NewUniqueHash f)) = do
modify $ \st -> st { stUniqStore = us }
return u >>= runTest . f
_ -> M.fail "uniq store ran out of elements"
-runTest (Free (NewUUID f)) = do
- word8s <- gets stWord8Store
- case word8s of
- -- note we use f' because f is a param of the function
- a:b:c:d:e:f':g:h:i:j:k:l:m:n:o:p:remaining -> do
- modify $ \st -> st { stWord8Store = remaining }
- return (UUID a b c d e f' g h i j k l m n o p) >>= runTest . f
- _ -> M.fail "word8 supply was not infinite"
runTest (Free (ReadFileStrict fp f)) = do
fps <- asks envFiles
case lookup fp fps of
diff --git a/src/Text/Pandoc/Writers/EPUB.hs b/src/Text/Pandoc/Writers/EPUB.hs
index 435893443..35724dfef 100644
--- a/src/Text/Pandoc/Writers/EPUB.hs
+++ b/src/Text/Pandoc/Writers/EPUB.hs
@@ -53,6 +53,7 @@ import Text.Pandoc.Options ( WriterOptions(..)
, ObfuscationMethod(NoObfuscation) )
import Text.Pandoc.Definition
import Text.Pandoc.Walk (walk, walkM, query)
+import Text.Pandoc.UUID (getUUID)
import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
import Control.Monad (mplus, when)
import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
@@ -152,7 +153,7 @@ getEPUBMetadata opts meta = do
let addIdentifier m =
if null (epubIdentifier m)
then do
- randomId <- fmap show (lift P.newUUID)
+ randomId <- (show . getUUID) <$> lift P.newStdGen
return $ m{ epubIdentifier = [Identifier randomId Nothing] }
else return m
let addLanguage m =