From 58488c6fec32f203dffb1d52f1499fe46cf40046 Mon Sep 17 00:00:00 2001 From: Hugo Pacheco Date: Wed, 12 Sep 2018 16:31:00 +0100 Subject: [PATCH 1/2] updated for ghc 8.4.2 --- Data/Graph/Analysis/Reporting/Pandoc.hs | 56 +++++++++++++++++-------- Graphalyze.cabal | 11 +++-- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/Data/Graph/Analysis/Reporting/Pandoc.hs b/Data/Graph/Analysis/Reporting/Pandoc.hs index bc32485..207773f 100644 --- a/Data/Graph/Analysis/Reporting/Pandoc.hs +++ b/Data/Graph/Analysis/Reporting/Pandoc.hs @@ -1,3 +1,5 @@ +{-# LANGUAGE CPP #-} + {- | Module : Data.Graph.Analysis.Reporting.Pandoc Description : Graphalyze Types and Classes @@ -39,6 +41,8 @@ import Data.List (intersperse) import Data.Maybe (fromJust, isNothing) import System.Directory (removeDirectoryRecursive) import System.FilePath ((<.>), ()) +import Data.Text (Text(..)) +import qualified Data.Text as T -- ----------------------------------------------------------------------------- @@ -46,8 +50,14 @@ import System.FilePath ((<.>), ()) The actual exported writers. -} +#if MIN_VERSION_pandoc (2,0,0) +writeHtmlStringGeneric = writeHtml5String +#else +writeHtmlStringGeneric = writeHtmlString +#endif + pandocHtml :: PandocDocument -pandocHtml = pd { writer = writeHtmlString +pandocHtml = pd { writer = writeHtmlStringGeneric , extension = "html" , templateName = "html" , extGraphProps = Just VProps { grSize = DefaultSize @@ -84,7 +94,11 @@ pandocMarkdown = pd { writer = writeMarkdown -- | Definition of a Pandoc Document. Size measurements are in inches, -- and a 6:4 ratio is used for width:length. data PandocDocument = PD { -- | The Pandoc document style +#if MIN_VERSION_pandoc (2,0,0) + writer :: WriterOptions -> Pandoc -> PandocPure Text +#else writer :: WriterOptions -> Pandoc -> String +#endif -- | The file extension used , extension :: FilePath -- | Which template to get. @@ -144,23 +158,29 @@ defaultProcess = PP { secLevel = 1 -- | Create the document. createPandoc :: PandocDocument -> Document -> IO (Maybe FilePath) -createPandoc p d = do created <- tryCreateDirectory dir - -- If the first one fails, so will this one. - _ <- tryCreateDirectory $ dir gdir - if not created - then failDoc - else do d' <- addLegend dir gdir (graphProps p) d - elems <- multiElems pp $ content d' - case elems of - Just es -> do let es' = htmlAuthDt : es - pnd = Pandoc meta es' - doc = convert pnd - wr <- tryWrite doc - case wr of - (Right _) -> success - (Left _) -> failDoc - Nothing -> failDoc - where +createPandoc p d = do + created <- tryCreateDirectory dir + -- If the first one fails, so will this one. + _ <- tryCreateDirectory $ dir gdir + if not created + then failDoc + else do + d' <- addLegend dir gdir (graphProps p) d + elems <- multiElems pp $ content d' + case elems of + Just es -> do + let es' = htmlAuthDt : es + pnd = Pandoc meta es' +#if MIN_VERSION_pandoc (2,0,0) + let doc = runPure $ convert pnd +#else + doc <- tryWrite $ convert pnd +#endif + case doc of + (Right _) -> success + (Left _) -> failDoc + Nothing -> failDoc + where dir = rootDirectory d gdir = graphDirectory d auth = author d diff --git a/Graphalyze.cabal b/Graphalyze.cabal index fe16cc8..5dd799d 100644 --- a/Graphalyze.cabal +++ b/Graphalyze.cabal @@ -1,5 +1,5 @@ Name: Graphalyze -Version: 0.15.0.0 +Version: 0.15.0.1 Synopsis: Graph-Theoretic Analysis library. Description: A library to use graph theory to analyse the relationships inherent in discrete data. @@ -13,8 +13,7 @@ Extra-Source-Files: TODO Cabal-Version: >= 1.6 Build-Type: Simple -Tested-With: GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, - GHC == 7.10.2, GHC == 7.11.* +Tested-With: GHC == 8.4.2 Source-Repository head Type: git @@ -35,9 +34,9 @@ Library { process, random, bktrees >= 0.2 && <0.4, - fgl == 5.5.*, - graphviz >= 2999.15 && < 2999.20, - pandoc == 1.19.*, + fgl == 5.6.*, + graphviz >= 2999.20 && < 2999.21, + pandoc >= 2.0 && < 2.3, text if flag(old-locale) { From 8806877d5a498a937277bac1035cb270b8edd15d Mon Sep 17 00:00:00 2001 From: Hugo Pacheco Date: Fri, 4 Jan 2019 23:49:52 +0000 Subject: [PATCH 2/2] 8.6 --- Graphalyze.cabal | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Graphalyze.cabal b/Graphalyze.cabal index 5dd799d..9616416 100644 --- a/Graphalyze.cabal +++ b/Graphalyze.cabal @@ -33,10 +33,10 @@ Library { filepath, process, random, - bktrees >= 0.2 && <0.4, - fgl == 5.6.*, - graphviz >= 2999.20 && < 2999.21, - pandoc >= 2.0 && < 2.3, + bktrees >= 0.2, + fgl >= 5.6, + graphviz >= 2999.20 , + pandoc >= 2.0 , text if flag(old-locale) {