git.iko.soy/typeable/pandoc
on master help sign in
Remove IO UUID functions.
commit7f4348f23f87f1990b794eb7f69c92ea3a839bfc authorJesse Rosenthal <jrosenthal@jhu.edu> dateSat 19 Nov 2016, 05:42 (10 years ago) parentaac3c9d
2 files changed+2−17
src/Text/Pandoc/Free.hs−16 src/Text/Pandoc/Writers/EPUB.hs+2−1
src/Text/Pandoc/Free.hs−16
@@ -45,7 +45,6 @@ module Text.Pandoc.Free ( PandocActionF(..)
4545 , getDefaultReferenceODT
4646 , newStdGen
4747 , newUniqueHash
48− , newUUID
4948 , readFileStrict
5049 , readFileLazy
5150 , readFileUTF8
@@ -81,8 +80,6 @@ import qualified Data.ByteString.Lazy as BL
8180import Control.Monad.Free
8281import qualified Control.Exception as E
8382import qualified System.Environment as IO (lookupEnv)
84−import Text.Pandoc.UUID
85−import qualified Text.Pandoc.UUID as IO (getRandomUUID)
8683import qualified Text.Pandoc.UTF8 as UTF8 (readFile, toString)
8784import System.FilePath.Glob (match, compile)
8885import System.FilePath ((</>))
@@ -100,7 +97,6 @@ data PandocActionF nxt =
10097 | GetDefaultReferenceODT (Maybe FilePath) (Archive -> nxt)
10198 | NewStdGen (StdGen -> nxt)
10299 | NewUniqueHash (Int -> nxt)
103− | NewUUID (UUID -> nxt)
104100 | ReadFileStrict FilePath (B.ByteString -> nxt)
105101 | ReadFileLazy FilePath (BL.ByteString -> nxt)
106102 | ReadFileUTF8 FilePath (String -> nxt)
@@ -137,9 +133,6 @@ newStdGen = liftF $ NewStdGen id
137133newUniqueHash :: PandocAction Int
138134newUniqueHash = liftF $ NewUniqueHash id
139135
140−newUUID :: PandocAction UUID
141−newUUID = liftF $ NewUUID id
142−
143136readFileStrict :: FilePath -> PandocAction B.ByteString
144137readFileStrict fp = liftF $ ReadFileStrict fp id
145138
@@ -183,7 +176,6 @@ runIO (Free (GetDefaultReferenceODT mfp f)) =
183176 IO.getDefaultReferenceODT mfp >>= runIO . f
184177runIO (Free (NewStdGen f)) = IO.newStdGen >>= runIO . f
185178runIO (Free (NewUniqueHash f)) = hashUnique <$> IO.newUnique >>= runIO . f
186−runIO (Free (NewUUID f)) = IO.getRandomUUID >>= runIO . f
187179runIO (Free (ReadFileStrict fp f)) = B.readFile fp >>= runIO . f
188180runIO (Free (ReadFileLazy fp f)) = BL.readFile fp >>= runIO . f
189181runIO (Free (ReadFileUTF8 fp f)) = UTF8.readFile fp >>= runIO . f
@@ -250,14 +242,6 @@ runTest (Free (NewUniqueHash f)) = do
250242 modify $ \st -> st { stUniqStore = us }
251243 return u >>= runTest . f
252244 _ -> 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"
261245runTest (Free (ReadFileStrict fp f)) = do
262246 fps <- asks envFiles
263247 case lookup fp fps of
src/Text/Pandoc/Writers/EPUB.hs+2−1
@@ -53,6 +53,7 @@ import Text.Pandoc.Options ( WriterOptions(..)
5353 , ObfuscationMethod(NoObfuscation) )
5454import Text.Pandoc.Definition
5555import Text.Pandoc.Walk (walk, walkM, query)
56+import Text.Pandoc.UUID (getUUID)
5657import Control.Monad.State (modify, get, gets, State, StateT, put, evalState, evalStateT, lift)
5758import Control.Monad (mplus, when)
5859import Text.XML.Light ( unode, Element(..), unqual, Attr(..), add_attrs
@@ -152,7 +153,7 @@ getEPUBMetadata opts meta = do
152153 let addIdentifier m =
153154 if null (epubIdentifier m)
154155 then do
155− randomId <- fmap show (lift P.newUUID)
156+ randomId <- (show . getUUID) <$> lift P.newStdGen
156157 return $ m{ epubIdentifier = [Identifier randomId Nothing] }
157158 else return m
158159 let addLanguage m =