aboutsummaryrefslogtreecommitdiff
path: root/haddock-api
diff options
context:
space:
mode:
authorAlex Biehl <alexbiehl@gmail.com>2017-05-12 21:02:33 +0200
committerGitHub <noreply@github.com>2017-05-12 21:02:33 +0200
commitb35eed2a9f1c82131f51f55c771ac2372127520d (patch)
tree0f2a534b9ef460f8c8e5db4df548f449e5cff30c /haddock-api
parentd300632cbc2346f6d95188426e5db5fbeb7c9f34 (diff)
Haddock: Fix broken lazy IO in prologue reading (#615)
We previously used withFile in conjunction with hGetContents. The list returned by the latter wasn't completely forced by the time we left the withFile block, meaning that we would try to read from a closed handle.
Diffstat (limited to 'haddock-api')
-rw-r--r--haddock-api/src/Haddock.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/haddock-api/src/Haddock.hs b/haddock-api/src/Haddock.hs
index 3971a5b7..f0e7e6c7 100644
--- a/haddock-api/src/Haddock.hs
+++ b/haddock-api/src/Haddock.hs
@@ -547,9 +547,10 @@ getPrologue :: DynFlags -> [Flag] -> IO (Maybe (MDoc RdrName))
getPrologue dflags flags =
case [filename | Flag_Prologue filename <- flags ] of
[] -> return Nothing
- [filename] -> withFile filename ReadMode $ \h -> do
+ [filename] -> do
+ h <- openFile filename ReadMode
hSetEncoding h utf8
- str <- hGetContents h
+ str <- hGetContents h -- semi-closes the handle
return . Just $! parseParas dflags str
_ -> throwE "multiple -p/--prologue options"