From 25bfa26554a0236ce21cef036609651cdcbc44aa Mon Sep 17 00:00:00 2001
From: John MacFarlane <jgm@berkeley.edu>
Date: Sat, 10 Jun 2017 21:10:52 +0200
Subject: [PATCH] Fixed weigh-pandoc for Text readers.

---
 Makefile                  | 5 ++++-
 benchmark/weigh-pandoc.hs | 5 +++--
 pandoc.cabal              | 1 +
 3 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 46ca7de9d..65cf3146e 100644
--- a/Makefile
+++ b/Makefile
@@ -18,6 +18,9 @@ test:
 bench:
 	stack bench
 
+weigh:
+	stack build --flag 'pandoc:weigh-pandoc' && stack exec weigh-pandoc
+
 reformat:
 	for f in $(sourcefiles); do echo $$f; stylish-haskell -i $$f ; done
 
@@ -62,4 +65,4 @@ download_stats:
 clean:
 	stack clean
 
-.PHONY: deps quick full install clean test bench changes_github macospkg dist prof download_stats reformat lint
+.PHONY: deps quick full install clean test bench changes_github macospkg dist prof download_stats reformat lint weigh
diff --git a/benchmark/weigh-pandoc.hs b/benchmark/weigh-pandoc.hs
index b4462d747..35296f925 100644
--- a/benchmark/weigh-pandoc.hs
+++ b/benchmark/weigh-pandoc.hs
@@ -1,5 +1,6 @@
 import Weigh
 import Text.Pandoc
+import Data.Text (Text, pack)
 
 main :: IO ()
 main = do
@@ -26,11 +27,11 @@ main = do
 weighWriter :: Pandoc -> String -> (Pandoc -> String) -> Weigh ()
 weighWriter doc name writer = func (name ++ " writer") writer doc
 
-weighReader :: Pandoc -> String -> (String -> Pandoc) -> Weigh ()
+weighReader :: Pandoc -> String -> (Text -> Pandoc) -> Weigh ()
 weighReader doc name reader = do
   case lookup name writers of
        Just (StringWriter writer) ->
-         let inp = either (error . show) id $ runPure $ writer def{ writerWrapText = WrapAuto} doc
+         let inp = either (error . show) pack $ runPure $ writer def{ writerWrapText = WrapAuto} doc
          in func (name ++ " reader") reader inp
        _ -> return () -- no writer for reader
 
diff --git a/pandoc.cabal b/pandoc.cabal
index 5ba020326..8d336097d 100644
--- a/pandoc.cabal
+++ b/pandoc.cabal
@@ -507,6 +507,7 @@ Executable weigh-pandoc
   if flag(weigh-pandoc)
      Build-Depends:   pandoc,
                       base >= 4.2 && < 5,
+                      text,
                       weigh >= 0.0 && < 0.1,
                       mtl >= 2.2 && < 2.3
      Buildable:       True