git.iko.soy/typeable/pandoc
on master help sign in
Remove IO UUID functions.
c9e6716Jesse Rosenthal
src/Text/Pandoc/Free.hs−16
@@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
45 , getDefaultReferenceODT
45 , getDefaultReferenceODT
46 , newStdGen
46 , newStdGen
47 , newUniqueHash
47 , newUniqueHash
48− , newUUID
49 , readFileStrict
48 , readFileStrict
50 , readFileLazy
49 , readFileLazy
51 , readFileUTF8
50 , readFileUTF8
@@ -81,8 +80,6 @@ import qualified Data.ByteString.Lazy as BL
81import Control.Monad.Free
80import Control.Monad.Free
82import qualified Control.Exception as E
81import qualified Control.Exception as E
83import qualified System.Environment as IO (lookupEnv)
82import qualified System.Environment as IO (lookupEnv)
84−import Text.Pandoc.UUID
85−import qualified Text.Pandoc.UUID as IO (getRandomUUID)
86import qualified Text.Pandoc.UTF8 as UTF8 (readFile, toString)
83import qualified Text.Pandoc.UTF8 as UTF8 (readFile, toString)
87import System.FilePath.Glob (match, compile)
84import System.FilePath.Glob (match, compile)
88import System.FilePath ((</>))
85import System.FilePath ((</>))
@@ -100,7 +97,6 @@ data PandocActionF nxt =
100 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
97 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
101 | NewStdGen (StdGen -> nxt)
98 | NewStdGen (StdGen -> nxt)
102 | NewUniqueHash (Int -> nxt)
99 | NewUniqueHash (Int -> nxt)
103− | NewUUID (UUID -> nxt)
104 | ReadFileStrict FilePath (B.ByteString -> nxt)
100 | ReadFileStrict FilePath (B.ByteString -> nxt)
105 | ReadFileLazy FilePath (BL.ByteString -> nxt)
101 | ReadFileLazy FilePath (BL.ByteString -> nxt)
106 | ReadFileUTF8 FilePath (String -> nxt)
102 | ReadFileUTF8 FilePath (String -> nxt)
@@ -137,9 +133,6 @@ newStdGen = liftF $ NewStdGen id
137newUniqueHash :: PandocAction Int
133newUniqueHash :: PandocAction Int
138newUniqueHash = liftF $ NewUniqueHash id
134newUniqueHash = liftF $ NewUniqueHash id
139
135
140−newUUID :: PandocAction UUID
141−newUUID = liftF $ NewUUID id
142−
143readFileStrict :: FilePath -> PandocAction B.ByteString
136readFileStrict :: FilePath -> PandocAction B.ByteString
144readFileStrict fp = liftF $ ReadFileStrict fp id
137readFileStrict fp = liftF $ ReadFileStrict fp id
145
138
@@ -183,7 +176,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
183 IO.getDefaultReferenceODT mfp >>= runIO . f
176 IO.getDefaultReferenceODT mfp >>= runIO . f
184runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
177runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
185runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
178runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
186−runIO (Free (NewUUID f)) = IO.getRandomUUID >>= runIO . f
187runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
179runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
188runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
180runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
189runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
181runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
@@ -250,14 +242,6 @@ runTest (Free (NewUniqueHash f)) = do
250 modify $ \st -> st { stUniqStore = us }
242 modify $ \st -> st { stUniqStore = us }
251 return u >>= runTest . f
243 return u >>= runTest . f
252 _ -> M.fail "uniq store ran out of elements"
244 _ -> M.fail "uniq store ran out of elements"
253−runTest (Free (NewUUID f)) = do
254− word8s <- gets stWord8Store
255− case word8s of
256− -- note we use f' because f is a param of the function
257− a:b:c:d:e:f':g:h:i:j:k:l:m:n:o:p:remaining -> do
258− modify $ \st -> st { stWord8Store = remaining }
259− return (UUID a b c d e f' g h i j k l m n o p) >>= runTest . f
260− _ -> M.fail "word8 supply was not infinite"
261runTest (Free (ReadFileStrict fp f)) = do
245runTest (Free (ReadFileStrict fp f)) = do
262 fps <- asks envFiles
246 fps <- asks envFiles
263 case lookup fp fps of
247 case lookup fp fps of
src/Text/Pandoc/Writers/EPUB.hs+2−1
@@ -53,6 +53,7 @@ import Text.Pandoc.Options ( WriterOptions(..)
53 , ObfuscationMethod(NoObfuscation) )
53 , ObfuscationMethod(NoObfuscation) )
54import Text.Pandoc.Definition
54import Text.Pandoc.Definition
55import Text.Pandoc.Walk (walk, walkM, query)
55import Text.Pandoc.Walk (walk, walkM, query)
56+import Text.Pandoc.UUID (getUUID)
56import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
57import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
57import Control.Monad (mplus, when)
58import Control.Monad (mplus, when)
58import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
59import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
@@ -152,7 +153,7 @@ getEPUBMetadata opts meta = do
152 let addIdentifier m =
153 let addIdentifier m =
153 if null (epubIdentifier m)
154 if null (epubIdentifier m)
154 then do
155 then do
155− randomId <- fmap show (lift P.newUUID)
156+ randomId <- (show . getUUID) <$> lift P.newStdGen
156 return $ m{ epubIdentifier = [Identifier randomId Nothing] }
157 return $ m{ epubIdentifier = [Identifier randomId Nothing] }
157 else return m
158 else return m
158 let addLanguage m =
159 let addLanguage m =