diff --git a/src/Language/Haskell/Exts.hs b/src/Language/Haskell/Exts.hs index f45d3923..f278679c 100644 --- a/src/Language/Haskell/Exts.hs +++ b/src/Language/Haskell/Exts.hs @@ -160,7 +160,9 @@ readUTF8File :: FilePath -> IO String readUTF8File fp = do h <- openFile fp ReadMode hSetEncoding h utf8 - hGetContents h + c <- hGetContents h >>= \s -> length s `seq` return s + hClose h + return c -- | Converts a parse result with comments to a parse result with comments and -- unknown pragmas. diff --git a/tests/Runner.hs b/tests/Runner.hs index 424a1618..5cff65b6 100644 --- a/tests/Runner.hs +++ b/tests/Runner.hs @@ -180,7 +180,9 @@ commentsTests dir = testGroup "Comments tests" $ do readUTF8File :: FilePath -> IO String readUTF8File fp = openFile fp ReadMode >>= \h -> do hSetEncoding h utf8 - hGetContents h + c <- hGetContents h >>= \s -> length s `seq` return s + hClose h + return c parseUTF8FileWithComments :: ParseMode -> FilePath -> IO (ParseResult (Module SrcSpanInfo, [Comment])) parseUTF8FileWithComments p fp = readUTF8File fp >>= (return . parseFileContentsWithComments p)