Gabriella439 / Gabriella439/Haskell-Pipes-Safe-Library
Make explicit buffering easier when using `withFile`
- Dominant language
- Haskell
- Stars
- 27
- Forks
- 22
- Avg merge
- 12d 10h
- Merged PRs (30d)
- 1
Description
I had a bug where my output file was always empty. I tracked it down to the default buffering mode. I think it would be better offer a variant of `withFile` that explicitly specifies the buffering mode.
What do you think?
```
withFile' :: MonadSafe m => FilePath -> IO.IOMode -> IO.BufferMode -> (IO.Handle -> m r) -> m r
withFile' file ioMode bufferMode = PS.bracket
(liftIO $ do
h <- IO.openFile file ioMode
IO.hSetBuffering h bufferMode
pure h)
(liftIO . IO.hClose)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the existing withFile entry point and checking how it opens and closes handles. Compare its behavior with the proposed withFile' signature and verify that explicit IO.BufferMode settings are applied correctly; done means callers can choose buffering without losing safe resource cleanup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100