Skip to content

Commit

Permalink
Fix withFileContents documentation
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
9999years committed Sep 27, 2024
1 parent c53a03a commit 892ef46
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cabal-syntax/src/Distribution/Utils/Generic.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 892ef46

Please sign in to comment.