From 76d5f2f866690e0a676898d5304b01c4c7fb3ad4 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 27 Sep 2024 11:50:17 -0700 Subject: [PATCH] Fix `withFileContents` documentation The documentation for `Distribution.Utils.Generic.withFileContents` is incorrect: $ cabal repl Cabal-syntax ghci> import Distribution.Utils.Generic ghci> withFileContents "README.md" $ \contents -> pure ("foo" `isInfixOf` contents) *** Exception: README.md: hGetContents: illegal operation (delayed read on closed handle) --- Cabal-syntax/src/Distribution/Utils/Generic.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cabal-syntax/src/Distribution/Utils/Generic.hs b/Cabal-syntax/src/Distribution/Utils/Generic.hs index 997e0132f5a..ace55a67aa3 100644 --- a/Cabal-syntax/src/Distribution/Utils/Generic.hs +++ b/Cabal-syntax/src/Distribution/Utils/Generic.hs @@ -153,8 +153,8 @@ wrapLine width = wrap 0 [] -- | Gets the contents of a file, but guarantee that it gets closed. -- --- The file is read lazily but if it is not fully consumed by the action then --- the remaining input is truncated and the file is closed. +-- The file is read lazily; if it is not fully consumed by the action then an +-- exception is thrown. withFileContents :: FilePath -> (String -> IO a) -> IO a withFileContents name action = withFile