From 0ef6a26d49fc2b3a5785a55d95b64f77c40e58ad Mon Sep 17 00:00:00 2001 From: alexbiehl Date: Sat, 3 Feb 2018 11:47:10 +0100 Subject: QuickJump: Mitigate encoding problems on Windows (cherry picked from commit 86292c54bfee2343aee84559ec01f1fc68f52231) --- haddock-api/src/Haddock/Backends/Xhtml.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'haddock-api/src/Haddock/Backends') diff --git a/haddock-api/src/Haddock/Backends/Xhtml.hs b/haddock-api/src/Haddock/Backends/Xhtml.hs index 55175163..2d23ddc7 100644 --- a/haddock-api/src/Haddock/Backends/Xhtml.hs +++ b/haddock-api/src/Haddock/Backends/Xhtml.hs @@ -36,11 +36,13 @@ import Text.XHtml hiding ( name, title, p, quote ) import Haddock.GhcUtils import Control.Monad ( when, unless ) +import qualified Data.ByteString.Builder as Builder import Data.Char ( toUpper, isSpace ) import Data.List ( sortBy, isPrefixOf, intercalate, intersperse ) import Data.Maybe -import System.FilePath hiding ( () ) import System.Directory +import System.FilePath hiding ( () ) +import qualified System.IO as IO import Data.Map ( Map ) import qualified Data.Map as Map hiding ( Map ) import qualified Data.Set as Set hiding ( Set ) @@ -353,9 +355,8 @@ ppJsonIndex :: FilePath -> IO () ppJsonIndex odir maybe_source_url maybe_wiki_url unicode qual_opt ifaces = do createDirectoryIfMissing True odir - writeFile (joinPath [odir, indexJsonFile]) - (encodeToString modules) - + IO.withFile (joinPath [odir, indexJsonFile]) IO.WriteMode $ \h -> do + Builder.hPutBuilder h (encodeToBuilder modules) where modules :: Value modules = Array (concatMap goInterface ifaces) -- cgit v1.2.3