base: add strict IO functions: readFile', getContents', hGetContents'
As proposed here https://mail.haskell.org/pipermail/libraries/2019-September/029964.html
Comment about the initial version of this MR (out of date)
The current implementation doesn't seem satisfactory, I'm looking for some advice about what it should actually do.
This new hGetContents'
just calls hGetContents
and forces the result, which unfortunately:
- swallows IO errors (the list just gets closed off, there is no way to distinguish it from a normal termination);
- is subject to the handle being closed concurrently (probably a minor problem).
I was thinking that instead it should throw any IO error it encounters, which seems to involve duplicating/reusing some of the current hGetContents
's logic.
Please take a few moments to verify that your commits fulfill the following:
-
are either individually buildable or squashed -
have commit messages which describe what they do (referring to Notes and tickets using #NNNN
syntax when appropriate) -
have added source comments describing your change. For larger changes you likely should add a Note and cross-reference it from the relevant places. -
add a testcase to the testsuite. -
Motivation: this adds Strict IO operations for "getting all input" from a handle, as previously only Lazy IO flavors of these functions only existed.
If you have any questions don't hesitate to open your merge request and inquire
in a comment. If your patch isn't quite done yet please do add prefix your MR
title with WIP:
.